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

WordPress Trac noreply at wordpress.org
Mon Apr 24 07:16: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 sebastian.pisula):

 I haven't control to overwrite meta value via get_post_metadata filter.
 Why? Because I can't check that post has _thumbnail_id.

 In my filter I can check:
 {{{#!php
 <?php
 if (empty ($ post_thumbnail_id)) {
 $post_thumbnail_id = 5;
 }

 return $post_thumbnail_id;
 }}}


 Additional solution is compatibility with has_post_thumbnail function :-)

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


More information about the wp-trac mailing list