Opened 4 years ago
Closed 4 years ago
#50160 closed defect (bug) (fixed)
Enable captions for image widgets with custom image size
Reported by: | kasparsd | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 5.4.1 |
Component: | Widgets | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Image widgets with image size set to "custom" and custom width and height values do not render captions on the widget output.
This happens because _wp_get_image_size_from_meta()
with custom
as the first parameter returns false
here and sets the $caption_size
value to false
which in turn causes $width
to be 0
which then disables caption output during img_caption_shortcode()
here.
Attachments (2)
Change History (10)
This ticket was mentioned in PR #269 on WordPress/wordpress-develop by kasparsd.
4 years ago
#1
Trac ticket: https://core.trac.wordpress.org/ticket/50160
Use the width
of a custom image size in an Image Widget instead of doing a lookup for an image size custom
which doesn't have a registered width and height.
This ensures that the $width
used for setting the caption width is not 0
and the captions are rendered for images with custom sizes.
4 years ago
#3
[The one failing Travis run](https://travis-ci.com/github/WordPress/wordpress-develop/jobs/333513693) appears to be a Travis issue.
#5
@
4 years ago
Tested on TwentySixteen and TwentyTwnety. The patch worked. I did not tested the Unit Test.
Demo of the image caption missing for images with custom sizes