[Support request] problem with svg logo since php8

Home Forums Support [Support request] problem with svg logo since php8

Home Forums Support problem with svg logo since php8

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #2384034
    Jens

    Hi Support-Team,
    i switched a website with php 7.4 and svg-logo zu php 8/8.1. after that there are problems with width and height of the svg-logo.
    error-message: undefinded array key width/height in header.php line 137+138

    when i change the logo to a png, i have no problems.

    can you reproduce that?

    regards, Jens

    #2384066
    David
    Staff
    Customer Support

    Hi there,

    do you have a custom header.php on your site ?

    #2384068
    Jens

    Hi David,
    no custom header.php

    #2384070
    David
    Staff
    Customer Support

    Odd, this is the themes header.php:
    https://github.com/tomusborne/generatepress/blob/master/header.php

    As you can see, its only 75 lines.
    But your error message refers to: in header.php line 137+138

    What am i missing πŸ™‚ ?

    #2384074
    Jens

    Oh, sorry, it was too short.
    it refers to generatepress/inc/structure/header.php

    #2384076
    David
    Staff
    Customer Support

    Well silly me – having a brain fog day today – please excuse me πŸ™‚

    So the SVG you have uploaded, if you view that in the Media Library – does it display any Width and Height attributes ?

    #2384083
    Jens

    No, there are no width and height. Is there something missing in the svg-file?

    #2384088
    David
    Staff
    Customer Support

    Can i see the site with that logo ?

    #2384095
    Jens

    the warning is in .inside-header

    #2384101
    David
    Staff
    Customer Support

    Ok, so the SVG does have width height and a valid viewbox attribute.
    But WP can have a hard time reading those for some unexplainable reason.

    Try the PHP Snippet provided here:

    https://docs.generatepress.com/article/generate_logo_output/#setting-a-width-and-height

    in this line add your width height attributes:

    <img width="999" height="999" class="header-image" src="%3$s" alt="%2$s" title="%2$s" />

    #2384116
    Jens

    thanks for the link, but i think its all ok with the site, only the php-warning crashes the layout.
    when i deactivate php-errors with ini_set(‘display_errors’,’off’); in wp-config.php its all fine. and i dont need the php snippet.

    #2384133
    David
    Staff
    Customer Support

    Just to note – that snippet will replace the missing width and height attributes in the img HTML. So it not only would fix that error, but it would make sure the Image has correct size attributes, without those you may get some CLS or resizing issues.

    #2384135
    Jens

    good to know, thanks a lot.

    #2384136
    David
    Staff
    Customer Support

    You’re welcome πŸ™‚

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.