[wp-trac] [WordPress Trac] #40096: get_post_thumbnail_id should return int

WordPress Trac noreply at wordpress.org
Fri Mar 10 14:28:05 UTC 2017


#40096: get_post_thumbnail_id should return int
-------------------------+-----------------------------
 Reporter:  0v3rth3d4wn  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  4.7.3
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 get_post_thumbnail_id returns string, which sometimes irritates me. I know
 that it actually returns get_post_meta, which returns string, but why
 don't cast it to int or wrap it in absint.
 {{{#!php
 <?php
 function get_post_thumbnail_id( $post = null ) {
     $post = get_post( $post );
     if ( ! $post ) {
           return '';
     }
     return absint( get_post_meta( $post->ID, '_thumbnail_id', true ) );
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40096>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list