• Resolved davewoodhall

    (@davewoodhall)


    In a custom widget area, I’ve added the built-in Image widget and I’m getting the following error :

    Warning: Illegal string offset 'width' in {{PATH_TO_ROOT}} /wp-includes/media.php on line 988

    As a reference, this is what I’m seeing between lines 985 and 999 :

    function _wp_get_image_size_from_meta( $size_name, $image_meta ) {
    	if ( $size_name === 'full' ) {
    		return array(
    			absint( $image_meta['width'] ),
    			absint( $image_meta['height'] ),
    		);
    	} elseif ( ! empty( $image_meta['sizes'][$size_name] ) ) {
    		return array(
    			absint( $image_meta['sizes'][$size_name]['width'] ),
    			absint( $image_meta['sizes'][$size_name]['height'] ),
    		);
    	}
    
    	return false;
    }

    The issue is with the $image_meta['width'] when using a SVG. It seems to me like it is not storing any information regarding size. I can understand since it is a vector file, but whenever I enable WP_DEBUG I get this problem.

    Thought it would be good to point this out.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Perhaps a plugin like this may help? https://www.ads-software.com/plugins/svg-support/
    I know SVG don’t usually work well with the media library.

    Thread Starter davewoodhall

    (@davewoodhall)

    Hi Kim,

    Thanks for the quick reply.

    I’ve seen this plugin in the past, but I’ve never really liked to depend on plugins. Since the image widget is now built-in, I just wanted to raise the flag since this is giving me errors.

    The plugin seems to be doing exactly what is expected of it, though. Thanks!

    Marked as resolved, but should be noted that the error is still part of the WP core.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Built-in Image Widget using SVG – Size issues’ is closed to new replies.