Archived topic
problem with svg logo since php8
13 replies · Started by Jens on October 24, 2022
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
Hi there,
do you have a custom header.php on your site ?
Hi David,
no custom header.php
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 :) ?
Oh, sorry, it was too short.
it refers to generatepress/inc/structure/header.php
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 ?
No, there are no width and height. Is there something missing in the svg-file?
Can i see the site with that logo ?
the warning is in .inside-header
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" />
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.
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.
good to know, thanks a lot.
You're welcome :)