Opened 4 years ago
Closed 4 years ago
#52183 closed defect (bug) (fixed)
get_the_post_thumbnail_url function returns original url if the size didnt exist
Reported by: | naveen17797 | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Post Thumbnails | Keywords: | has-patch commit |
Focuses: | docs | Cc: |
Description
From the function description it should return false if the size does not exist.
Steps to replicate the issue
- I uploaded a image via featured image field on the post edit screen.
- I am calling this function inside the theme file like this
$medium_thumbnail_url = get_the_post_thumbnail_url( $post_id, 'medium');
But this function returns original url instead of returning false.
Attachments (3)
Change History (11)
#3
@
4 years ago
@naveen17797 Your are confused because the @return
description contains a mistake. It should be no image
instead of no URL
.
@SergeyBiryukov I attached a patch to update the @return
description based on the wp_get_attachment_image_url
description.
I don't know if we should be more specific in case the $size
doesn't match a registered image.
e.g:
@return string|false Post thumbnail URL or false if no image is available. If `$size` doesn't match a registerd image size, the original thumbnail URL will be returned.
#4
@
4 years ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 5.7
- Owner set to audrasjb
- Status changed from new to accepted
- Version 5.6 deleted
Hi, thanks for the patch @GeekPress,
@return string|false Post thumbnail URL or false if no image is available. If `$size` doesn't match a registered image size, the original thumbnail URL will be returned.
This proposal looks great to me. Can you please update the patch accordingly?
#5
@
4 years ago
Maybe just replace "the original thumbnail URL will be returned" with "the original image URL will be returned".
@
4 years ago
More specific @return description for wp_get_attachment_image_url & get_the_post_thumbnail_url
#6
@
4 years ago
Thanks @audrasjb for your feedback.
I've updated the patch. I also updated the @return
description of wp_get_attachment_image_url
to have the same @return
statement than get_the_post_thumbnail_url
Additional information:
I disabled the medium size by going to settings > Media > setting the dimensions to 0x0
It wont be generated for any image, After featured image upload, the medium size image is not generated