Open cadic opened 2 years ago
As mentioned in my comments to the PR#44 https://github.com/10up/safe-svg/pull/44#discussion_r830032815 and https://github.com/10up/safe-svg/pull/44#discussion_r830029068, 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.
@darylldoyle any thoughts on how best to handle this issue?
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