Opened 11 years ago
Last modified 5 years ago
#24815 new defect (bug)
get_the_post_thumbnail() fetches full sized image if 'post-thumbnail' custom size not defined in theme
Reported by: | Jonnyauk | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.9 |
Component: | Media | Keywords: | needs-codex has-patch needs-refresh |
Focuses: | Cc: |
Description
In wp-includes/post-thumbnail-template.php the $size default value is set as 'post-thumbnail' in the following function:
- get_the_post_thumbnail()
Expected behaviour
Expected behaviour would be to return the image at 'post-thumbnail' dimensions - however, if this is not set in the theme via:
- set_post_thumbnail_size() function
- add_image_size() function
it returns the full sized sized image begin displayed. I'd expect this to return the image at standard 'thumbnail' size, as some people will just add add_theme_support( 'post-thumbnails' ) and not set (or even need) custom dimensions.
Proposal and patch
$size default value should default back to 'thumbnail' for normal expected function behaviour if 'post-thumbnail' specific dimensions have not been set.
I'm not sure if it would be more efficient to test against the global variable that holds these values, or use get_intermediate_image_sizes() as I've used in the patch attached - 2nd opinion please?
Attachments (1)
Change History (6)
#2
@
11 years ago
- Version changed from trunk to 2.9
Originally post-thumbnail-template.php was only included if the theme actually supported post thumbnails. The only reason why it isn't is because the conditional loading of the file was silly for opcode caching purposes. I'm not sure there is anything we should do here. 'post-thumbnail' is realistically required for these functions.
#3
@
11 years ago
I understand where you are coming from on this, thank you for your feedback. However, in the patch I still check against 'post-thumbnail', so there won't be any compatibility issues.
It seems a-little strange behaviour to me to have to define another image size for 'post-thumbnail' for this to function correctly, I'd expect it to default to standard thumbnail dimensions (due to the name of the function?)
Patch v1 - uses get_intermediate_image_sizes()