Opened 7 years ago
Closed 7 years ago
#42863 closed defect (bug) (invalid)
Wrong default-value for $size in get_the_post_thumbnail_url()
Reported by: |
|
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()
- https://github.com/WordPress/WordPress/blob/master/wp-includes/post-thumbnail-template.php#L196
- default for $size = post-thumbnail
wp_get_attachment_image_url()
- https://github.com/WordPress/WordPress/blob/master/wp-includes/media.php#L944
- default for $size = thumbnail
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)
Note: See
TracTickets for help on using
tickets.
Hi @souri_wpaustria,
Thanks for the report. In this case,
post-thumbnail
is the intended default size since the functionget_the_post_thumbnail_url()
is meant to return thepost-thumbnail
size set when a theme declares post thumbnail support and usesset_post_thumbnail_size()
to set the size for thepost-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.