[wp-trac] [WordPress Trac] #23983: Add filter to get_post_thumbnail_id to override default thumbnail use

WordPress Trac noreply at wordpress.org
Fri Oct 6 14:36:01 UTC 2017


#23983: Add filter to get_post_thumbnail_id to override default thumbnail use
-------------------------------------------------+-------------------------
 Reporter:  Jesper800                            |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Media                                |  Review
 Severity:  normal                               |     Version:
 Keywords:  2nd-opinion needs-testing has-patch  |  Resolution:
                                                 |     Focuses:
-------------------------------------------------+-------------------------

Comment (by leogermani):

 +1 for this

 hooking in get_%type%_metadata is messy, because you can not easily check
 wether the post has a post thumbnail or not inside your filter, you would
 end up in an endless loop if you call has_post_thumbnail()

 In that case you have to do something like inside your callback:

 $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key =
 '_thumbnail_id' AND post_id = $object_id");

 not really beautiful.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/23983#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list