Opened 4 years ago
Closed 4 years ago
#51362 closed defect (bug) (fixed)
Allow gallery_shortcode() and get_image_tag() to accept an array of image dimensions
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
Of all the image-related functions in WordPress that include a $size
parameter, almost all of them accept either a registered image size or an array of the image width and height in pixels.
There are three exceptions to this, which do not accept an array:
gallery_shortcode()
($attr['size']
parameter) because the value gets passed tosanitize_html_class()
get_image_tag()
because the value gets directly used as an HTML attributeget_image_send_to_editor()
because the value gets passed toget_image_tag()
The gallery_shortcode()
and image_tag()
functions should be fixed so that they use {$width}x{$height}
where the image size is used as an HTML attribute. This is what wp_get_attachment_image()
already does when its $size
parameter is an array.
The documentation for these functions and their filters are currently incorrect because they state that they do accept either an image name or array of dimensions, therefore this is a backwards-compatible fix.
Related / split from #47364.
51362.diff fixes these two instances.