Opened 8 years ago
Last modified 6 years ago
#43046 assigned defect (bug)
`has_image_size()` returns false for Core image sizes
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | minor | Version: | 3.9 |
| Component: | Media | Keywords: | has-patch dev-feedback has-unit-tests needs-refresh |
| Focuses: | Cc: |
Description
has_image_size() returns false (does not exist) for the four core image sizes (thumbnail, medium, medium_large, large).
get_intermediate_image_sizes() returns these core image sizes merged with custom registered sizes through add_image_size().
has_image_size() should return true for the core image sizes, or the function docs should note that the core image sizes are not checked in the function.
Attachments (3)
Change History (14)
@
8 years ago
Introduce second parameter to has_image_size() to use core image sizes and update docs.
This ticket was mentioned in Slack in #core-media by desrosj. View the logs.
8 years ago
#4
@
8 years ago
- Keywords dev-feedback added
- Milestone changed from Awaiting Review to 5.0
- Owner set to desrosj
- Status changed from new to assigned
#5
@
8 years ago
I suspect this will need some research to find out the effects for backcompat on each way of fixing this, and how much a param will help. After a chat in #core-media about it, @desrosj offered to do some digging.
This ticket was mentioned in Slack in #core-media by desrosj. View the logs.
8 years ago
#8
@
7 years ago
- Milestone changed from 5.0 to 5.1
This still needs some research and falls outside of the 5.0 focus. Punting to 5.1.
This ticket was mentioned in Slack in #core-media by desrosj. View the logs.
7 years ago
#10
@
7 years ago
- Keywords needs-refresh added
- Milestone changed from 5.1 to Future Release
@andizer thanks for those tests! More code would need to be added for the second one to be accurate, though, as has_image_size() does not currently accept a second parameter.
I am going to punt this to Future Release. This could just be a simple docs change to indicate core image sizes are excluded, or an added parameter. But the implications of the second option are not yet clear.
has_image_size()function is specifically used for image sizes that are registered viaadd_image_size()function. It is actually usingwp_get_additional_image_sizes()function, which does not consider core image sizes.On the other hand
get_intermediate_image_sizes()uses the same function (wp_get_additional_image_sizes()) but it forcefully defines an array of core image sizes and merges it with the array returned bywp_get_additional_image_sizes()function.I agree with @desrosj that the documentation has to be more clear about the limitation.
I have edited description at https://codex.wordpress.org/Function_Reference/has_image_size