• Resolved anderssonkax

    (@anderssonkax)


    Using WP 6.1.1 + Twenty Twenty One 1.7 + Twentig 1.5.2 on a WordOps configuration with NGINX + FastCGI, I decided to upgrade from PHP 7.4 to PHP 8.1 as it’s approaching end of life.

    After the update, I faced a “There has been a critical error on this website”, and a 500 error after the GET request in console. I was still able to log in to the dashboard in a different browser, but as soon as I tried to preview a post the same error popped up. Weird.

    Anyways, after digging through the error logs I found this:

    FastCGI sent in stderr: “PHP message: PHP Warning: Division by zero in /var/www/SITENAMEREDACTED.com/htdocs/wp-content/plugins/twentig/inc/classic/twentytwentyone/front-style.php on line 743PHP message: PHP Warning: Division by zero in /var/www/SITENAMEREDACTED.com/htdocs/wp-content/plugins/twentig/inc/classic/twentytwentyone/front-style.php on line 747”

    And after digging deeper I found that this could be related to the site logo being in SVG format. So I tried switching the logo to JPG and voila! The error was gone.

    That said, I’d like to be able to use the SVG format in my site logo — any suggestions on how to fix this?

    • This topic was modified 2 years ago by anderssonkax. Reason: added theme and plugin versions
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Yann

    (@collet)

    Hi,

    Twentig uses the dimensions of the uploaded logo to calculate some values for layout purposes. Can you please tell me which method (plugin, custom code…) you’re using to upload your SVG file?

    Also would you please send me the code of your SVG file so I can try to replicate the issue on my side? (the SVG should contain the width and height attributes)

    Thanks,
    Yann

    Thread Starter anderssonkax

    (@anderssonkax)

    I’ve activated SVG use by including the following snippet in my child theme’s functions.php (as per csstricks.com):

    function w3reign_svg_mime_type( $mimes = array() ) {
      $mimes['svg']  = 'image/svg+xml';
      $mimes['svgz'] = 'image/svg+xml';
      return $mimes;
    }
    add_filter( 'upload_mimes', 'w3reign_svg_mime_type' );

    Any SVG image I upload is displayed using an img tag and the direct path to the image, and not SVG code. I also don’t have any image dimensions available in the media library for SVG images, as wordpress does not recognize them as images but rather documents.

    The odd thing here is that everything has worked fine up until updating to PHP 8.4.

    Plugin Support Yann

    (@collet)

    We have just released Twentig 1.5.3, which should prevent the PHP error from showing up when the uploaded logo has no dimensions. That said, I would recommend using a plugin like Safe SVG to upload your SVG safely.

    Have a nice day,
    Yann

    Thread Starter anderssonkax

    (@anderssonkax)

    Thanks for the swift follow-up Yann.

    Since it’s worked without any issues for years I’m hesitant to install a whole new plugin for something that has been solved with four lines of code previously.

    For now, I’ll use jpg for the logo to avoid site-breaking issues or having to install unnecessary plugins.

    Plugin Support Yann

    (@collet)

    Thank you for the heads up. Would you mind leaving us a quick review on our plugin page? This allows us to continue providing great features and helps other users to find us.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Twentig seems to break SVG logos on PHP 8.1’ is closed to new replies.