• Resolved shamank

    (@shamank)


    Hi! I’m using PHP 7.1, WP 5.0.2 and Avada theme. I realized that in some cases (I’m not which ones), the error log is showing me errors with the size of some svg images:

    PHP Warning:  Illegal string offset 'width' in /blablabla/wp-includes/media.php on line 988
    PHP Warning:  Illegal string offset 'height' in /blablabla/wp-includes/media.php on line 989
    

    I fixed it with a custom function in my child theme (a filter to modify the returned value in wp-includes/post.php => wp_get_attachment_metadata()) that simply returns false when some of these properties are not present:

     14 function wp_get_attachment_metadata_mine($data) {
     15 
     16     $res = $data;
     17     if (!isset($data['width']) || !isset($data['height'])) {
     18         $res = false;
     19     }
     20 
     21     return $res;                                                                                                                                                            
     22 }
     23 add_filter( 'wp_get_attachment_metadata' , 'wp_get_attachment_metadata_mine' );
    

    I saw this error in some other sites (of mine), so I was wondering if you could “fix” this in some way in your plugin. I’m not a WP dev so I’m not sure it’s possible.

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hey there,

    Yeah this PHP warning is usually fired by the image widget. I have a few things like this to work into the plugin. It’s just been absolutely crazy for a while and I haven’t had the time I’d like to put in.

    Hopefully I can dedicate some solid time soon to get this addressed, along with a few other things and some better integration with the new block editor.

Viewing 1 replies (of 1 total)

The topic ‘PHP Warning: Illegal string offset ‘height’ / ‘width’’ is closed to new replies.