mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Media: Add filter for post thumbnail id.
Introduces new filter `post_thumbnail_id` which allows overriding the default id returned from `get_post_thumbnail_id()`. Props engelen, alexvorn2, gilbitron, sebastianpisula, SergeyBiryukov, leogermani, rzen, joemcgill, audrasjb. Fixes #23983. git-svn-id: https://develop.svn.wordpress.org/trunk@52028 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -57,7 +57,17 @@ function get_post_thumbnail_id( $post = null ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (int) get_post_meta( $post->ID, '_thumbnail_id', true );
|
||||
$thumbnail_id = (int) get_post_meta( $post->ID, '_thumbnail_id', true );
|
||||
|
||||
/**
|
||||
* Filters post thumbnail ID.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param int|false $thumbnail_id Post thumbnail ID or false if the post does not exist.
|
||||
* @param int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`.
|
||||
*/
|
||||
return (int) apply_filters( 'post_thumbnail_id', $thumbnail_id, $post );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user