• Hello,

    I noticed that the plugin is now supporting height / width metadata for svgs which is great. The code is extracting these attributes when found on the svg, but my client is uploading svgs that only have the viewBox attribute and no width/height attributes.

    
    $svg = simplexml_load_file( $svg );
    
    	if ( $svg === FALSE ) {
    
    		$width = '0';
    		$height = '0';
    
    	} else {
    
    		$attributes = $svg->attributes();
    		$width = (string) $attributes->width;
    		$height = (string) $attributes->height;
    
    	}
    

    Would it be possible to extract the dimension from viewBox=”0 0 400 200″ if a viewBox attribute is found and that the svg doesn’t have width/height attributes.

    It would help performance and improve lighthouse score with these svgs.

    Thank you.

  • The topic ‘Height / Width not set when svg is only using viewBox’ is closed to new replies.