WordPress.org

Make WordPress Core

#42863 closed defect (bug) (invalid)

Wrong default-value for $size in get_the_post_thumbnail_url()

Reported by: souri_wpaustria Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.1
Component: Media Keywords:
Focuses: Cc:

Description

If you use get_the_post_thumbnail_url() without setting the $size value, it seems that get_the_post_thumbnail_url() doesn't work!

Look here:

get_the_post_thumbnail_url()

wp_get_attachment_image_url()

So if you want to use get_the_post_thumbnail_url() correctly, you have to specify $size = 'thumbnail'. Otherwise it doesn't work, because the default is "post_thumbnail" and this is meh.

Change History (1)

#1 @joemcgill
18 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @souri_wpaustria,

Thanks for the report. In this case, post-thumbnail is the intended default size since the function get_the_post_thumbnail_url() is meant to return the post-thumbnail size set when a theme declares post thumbnail support and uses set_post_thumbnail_size() to set the size for the post-thumbnail image.

At this point, the function has defaulted to the post-thumbnail size since it was introduced in 4.4, so changing the default value would result in backwards compatibility issues for any themes that are expecting the current default size.

Note: See TracTickets for help on using tickets.