_wp_preview_post_thumbnail_filter
Filters post thumbnail lookup to set the post thumbnail.
Description
Returns (null|array)
The default return value or the post thumbnail meta array.
Parameters (3)
- 0. $value (null|array|string)
- The value to return - a single metadata value, or an array of values.
- 1. $post_id (int)
- The post id.
- 2. $meta_key (string)
- The meta key.
Usage
if ( !function_exists( '_wp_preview_post_thumbnail_filter' ) ) { require_once ABSPATH . WPINC . '/revision.php'; } // The value to return - a single metadata value, or an array of values. $value = null; // The post id. $post_id = -1; // The meta key. $meta_key = ''; // NOTICE! Understand what this does before running. $result = _wp_preview_post_thumbnail_filter($value, $post_id, $meta_key);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/revision.php
- 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 );
- }