Make WordPress Core

Opened 3 years ago

#40096 new enhancement

get_post_thumbnail_id should return int

Reported by: 0v3rth3d4wn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.3
Component: General Keywords:
Focuses: Cc:
PR Number:


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.

function get_post_thumbnail_id( $post = null ) {
    $post = get_post( $post );
    if ( ! $post ) {
          return '';
    return absint( get_post_meta( $post->ID, '_thumbnail_id', true ) );

Change History (0)

Note: See TracTickets for help on using tickets.