Update how custom svg dimesions are applied#216
Conversation
Update how custom svg dimesions are applied for `get_image_tag` and `wp_get_attachment_image` functions Separate the logic for defining custom dimensions in a `set_svg_dimension` function
|
@gabriel-glo thanks for the PR! Could you please fill out the PR template with description, changelog, and credits information so that we can properly review and merge this? |
iamdharmesh
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR @gabriel-glo. Code looks good and it tests well. (Added one minor doc update suggestion)
@dkotter The PR looks good to me. However, since we had 2-3 size/dimension-related PRs on this plugin earlier and you have better context on those, I wanted to have a quick review from your side to ensure these changes align with those PRs.
Thank you.
Co-authored-by: Darin Kotter <darin.kotter@gmail.com>
There was a problem hiding this comment.
This looks good to me now. Tested with both get_image_tag and wp_get_attachment_image and verified things worked as expected with both. Testing on the latest release and on this PR, get_image_tag returns the exact same output. Testing wp_get_attachment_image, on the latest release, if you pass in an array of sizes, those values aren't being used. On this PR, those sizes are now respected and set properly as the height and width attributes.
|
This breaks behavior in wp_get_attachment_image(): Reverting this helps: |
Description of the Change
get_image_tagandwp_get_attachment_imagefunctionsset_svg_dimensionfunctionCloses #6
How to test the Change
In any template output the image markup either by using
get_image_tagorwp_get_attachment_imagefunctions.Set the custom image size to either one of the registered image size names or a custom one via array
[$width, $height].Output should match the set dimensions.
Changelog Entry
Credits
Props @gabriel-glo, @jeremymoore, @iamdharmesh, @dkotter
Checklist: