_wp_preview_post_thumbnail_filter

The timeline below displays how wordpress function _wp_preview_post_thumbnail_filter has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Filters post thumbnail lookup to set the post thumbnail.
 *
 * @since 4.6.0
 * @access private
 *
 * @param null|array|string $value    The value to return - a single metadata value, or an array of values.
 * @param int               $post_id  Post ID.
 * @param string            $meta_key Meta key.
 * @return null|array The default return value or the post thumbnail meta array.
 */
function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key)
{
    $post = get_post();
    if (!$post) {
        return $value;
    }
    if (empty($_REQUEST['_thumbnail_id']) || empty($_REQUEST['preview_id']) || $post->ID !== $post_id || $post_id !== (int) $_REQUEST['preview_id'] || '_thumbnail_id' !== $meta_key || 'revision' === $post->post_type) {
        return $value;
    }
    $thumbnail_id = (int) $_REQUEST['_thumbnail_id'];
    if ($thumbnail_id <= 0) {
        return '';
    }
    return (string) $thumbnail_id;
}

WordPress Version: 5.6

/**
 * Filters post thumbnail lookup to set the post thumbnail.
 *
 * @since 4.6.0
 * @access private
 *
 * @param null|array|string $value    The value to return - a single metadata value, or an array of values.
 * @param int               $post_id  Post ID.
 * @param string            $meta_key Meta key.
 * @return null|array The default return value or the post thumbnail meta array.
 */
function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key)
{
    $post = get_post();
    if (!$post) {
        return $value;
    }
    if (empty($_REQUEST['_thumbnail_id']) || empty($_REQUEST['preview_id']) || $post->ID != $post_id || '_thumbnail_id' !== $meta_key || 'revision' === $post->post_type || $post_id != $_REQUEST['preview_id']) {
        return $value;
    }
    $thumbnail_id = (int) $_REQUEST['_thumbnail_id'];
    if ($thumbnail_id <= 0) {
        return '';
    }
    return (string) $thumbnail_id;
}

WordPress Version: 5.5

/**
 * Filters post thumbnail lookup to set the post thumbnail.
 *
 * @since 4.6.0
 * @access private
 *
 * @param null|array|string $value    The value to return - a single metadata value, or an array of values.
 * @param int               $post_id  Post ID.
 * @param string            $meta_key Meta key.
 * @return null|array The default return value or the post thumbnail meta array.
 */
function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key)
{
    $post = get_post();
    if (!$post) {
        return $value;
    }
    if (empty($_REQUEST['_thumbnail_id']) || empty($_REQUEST['preview_id']) || $post->ID != $post_id || '_thumbnail_id' !== $meta_key || 'revision' === $post->post_type || $post_id != $_REQUEST['preview_id']) {
        return $value;
    }
    $thumbnail_id = intval($_REQUEST['_thumbnail_id']);
    if ($thumbnail_id <= 0) {
        return '';
    }
    return strval($thumbnail_id);
}

WordPress Version: 5.3

/**
 * Filters post thumbnail lookup to set the post thumbnail.
 *
 * @since 4.6.0
 * @access private
 *
 * @param null|array|string $value    The value to return - a single metadata value, or an array of values.
 * @param int               $post_id  Post ID.
 * @param string            $meta_key Meta key.
 * @return null|array The default return value or the post thumbnail meta array.
 */
function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key)
{
    $post = get_post();
    if (!$post) {
        return $value;
    }
    if (empty($_REQUEST['_thumbnail_id']) || empty($_REQUEST['preview_id']) || $post->ID != $post_id || '_thumbnail_id' != $meta_key || 'revision' == $post->post_type || $post_id != $_REQUEST['preview_id']) {
        return $value;
    }
    $thumbnail_id = intval($_REQUEST['_thumbnail_id']);
    if ($thumbnail_id <= 0) {
        return '';
    }
    return strval($thumbnail_id);
}

WordPress Version: 6.1

/**
 * Filters post thumbnail lookup to set the post thumbnail.
 *
 * @since 4.6.0
 * @access private
 *
 * @param null|array|string $value    The value to return - a single metadata value, or an array of values.
 * @param int               $post_id  Post ID.
 * @param string            $meta_key Meta key.
 * @return null|array The default return value or the post thumbnail meta array.
 */
function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key)
{
    if (!$post = get_post()) {
        return $value;
    }
    if (empty($_REQUEST['_thumbnail_id']) || empty($_REQUEST['preview_id']) || $post->ID != $post_id || '_thumbnail_id' != $meta_key || 'revision' == $post->post_type || $post_id != $_REQUEST['preview_id']) {
        return $value;
    }
    $thumbnail_id = intval($_REQUEST['_thumbnail_id']);
    if ($thumbnail_id <= 0) {
        return '';
    }
    return strval($thumbnail_id);
}

WordPress Version: 4.6

/**
 * Filters post thumbnail lookup to set the post thumbnail.
 *
 * @since 4.6.0
 * @access private
 *
 * @param null|array|string $value    The value to return - a single metadata value, or an array of values.
 * @param int               $post_id  Post ID.
 * @param string            $meta_key Meta key.
 * @return null|array The default return value or the post thumbnail meta array.
 */
function _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key)
{
    if (!$post = get_post()) {
        return $value;
    }
    if (empty($_REQUEST['_thumbnail_id']) || $post->ID != $post_id || '_thumbnail_id' != $meta_key || 'revision' == $post->post_type) {
        return $value;
    }
    $thumbnail_id = intval($_REQUEST['_thumbnail_id']);
    if ($thumbnail_id <= 0) {
        return '';
    }
    return strval($thumbnail_id);
}