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
The SVG support plugins I have tried all don't filter the image dimensions of SVGs, at least incompletely
(see these posts/issues for plugin SVG Support; Safe SVG; WP SVG images).
A non-zero fallback would also suffice to fix this issue.
function _svg_dims_fallback_is_svg($image_attachment_id)
{
$image_mime_type = get_post_mime_type($image_attachment_id);
return 'image/svg+xml' === $image_mime_type;
}
function svg_dims_fallback($image, $attachment_id, $size, $icon)
{
if (!_svg_dims_fallback_is_svg($attachment_id)) {
return $image; // skip non-SVGs
}
// set some non-zero defaults to prevent division by zero in Gutenberg site-logo render
if(!isset($image[1]) or $image[1] === 0) {
$image[1] = 1;
}
if(!isset($image[2]) or $image[2] === 0) {
$image[2] = 1;
}
return $image;
}
add_filter( 'wp_get_attachment_image_src', 'svg_dims_fallback', 10, 4 );
The filter has to be set up in a plugin so it runs before the Gutenberg site logo render function.
WordPress/gutenberg#36603 (comment)
The text was updated successfully, but these errors were encountered: