You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When inserting SVG to the post, or using wp_get_attachment_image() function with custom image size ('large', 'medium', 'thumbnail', etc.) we always receive the full SVG src (which is normal) and incorrect (full-size or square) image dimensions in width and height attributes.
Regardless of the selected Image Size in the Block Properties, the Image Dimensions remain the same (full size) and the resulting image still have full dimensions in width and height attributes. Expected to have width="300" height="152" in this example
As mentioned in my comments to the PR#44 #44 (comment) and #44 (comment), the root cause is WordPress core function image_downsize() which always returns square size for SVG images, even if they are rectangular.
The image_downsize filter allows us to make custom image size calculations.
Describe the bug
When inserting SVG to the post, or using
wp_get_attachment_image()
function with custom image size ('large', 'medium', 'thumbnail', etc.) we always receive the full SVG src (which is normal) and incorrect (full-size or square) image dimensions in width and height attributes.Steps to Reproduce
Displaying SVG programmatically
Both resulting images have the same width and height. Expected to have 300x152 for medium size.
Adding SVG in Block Editor
Regardless of the selected Image Size in the Block Properties, the Image Dimensions remain the same (full size) and the resulting image still have full dimensions in width and height attributes. Expected to have
width="300" height="152"
in this exampleAdding SVG in Classic Editor
The image width and height attributes respect the selected size (medium) but represent the square 300x300. Expected to have the
height="152"
Environment information
Previous release Safe SVG 1.9.9
(or
develop
with mergedfix/23
)Code of Conduct
The text was updated successfully, but these errors were encountered: