• Resolved jinsley8

    (@jinsley8)


    Hi,

    I’m testing updating a server to PHP 8.0 and on the frontend pages I’m getting the following PHP Warnings now.

    Undefined variable $viewbox_width – wp-content/plugins/safe-svg/safe-svg.php:507
    Undefined variable $viewbox_height – wp-content/plugins/safe-svg/safe-svg.php:508

    15 warnings for each one – how to I correct this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jinsley8

    (@jinsley8)

    Actually, I just noticed if I switch back to PHP 7.4 it changes to PHP notice, not warning.

    How can we fix this?

    Version 2.0.0 introduced some changed to fix of width/height of the SVGs.
    But the introduced part could be improved.
    Now it’s forcing to use dimensions found in Viewbox even if they are not found at all i.e. SVG file is not having viewbox.
    In that scenario variables $viewbox_width/$viewbox_height are not set but despite that code in safe-svg.php:507,508 uses those variables to set width/height of SVG.

    In my case that resulted in SVGs being output as 100x100px (kind of default fallback) despite them having explicit width/height set because that file didn’t have Viewbox set at all.

    Yes, I can use the new filter “safe_svg_use_width_height_attributes” but that seems to be more like a temporary workaround.

    Code logic in this place should be improved to check if there are actually viewbox values to set before using them.

    Plugin Contributor Jeffrey Paul

    (@jeffpaul)

    Note that v2.0.1 was just released, would be curious if you’re all still experiencing issues or not… thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP 8.0 – Undefined variable $viewbox_width’ is closed to new replies.