• After upgrading Safe SVG from 1.9.8 to 1.9.9, almost all svg images are shown as width=100 and height=100 regardless actual image size.

    I investigated the changelogs, and found added code:
    is_numeric( $attributes->width ) && is_numeric( $attributes->height )

    $attributes->width and $attributes->height are object(SimpleXMLElement), not string, therefore is_numeric( $attributes->width ) and is_numeric( $attributes->height ) always return false. So default image size (width=100 and height=100) are applied.

    To modify this problem, the code is to be:
    is_numeric( (string)$attributes->width ) && is_numeric( (string)$attributes->height )

Viewing 2 replies - 1 through 2 (of 2 total)
  • Same problem!

    My header logo appears small af, how can I solve it? Changing those right? But where in the code can I find that part? I’m loosing my mind

    is_numeric( $attributes->width ) && is_numeric( $attributes->height )
    
    

    is_numeric( (string)$attributes->width ) && is_numeric( (string)$attributes->height )

    • This reply was modified 3 years, 11 months ago by bintexenergy.
    • This reply was modified 3 years, 11 months ago by bintexenergy.

    Better and simpler workaround is to replace
    $attributes = $svg->attributes();
    with
    $attributes = (object) current( $svg->attributes() );
    in order to get a flatten object of attributes.

    For those asking, it’s line 428 in safe-svg.php file

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘1.9.9 doesn’t return correct width and height’ is closed to new replies.