1

When publishing a post or page that includes trusted SVG files in the content, WordPress spits out the errors Undefined array key "width" in wp-admin/includes/image.php and Undefined array key "height" in wp-admin/includes/image.php. The SVG files are uploaded with the upload_mimes filter.

function file_mime_type( $mimes ) {
    if( is_user_logged_in() && ! current_user_can( 'activate_plugins' ) ) {
        return $mimes;
    }
    
    if( is_user_logged_in() && current_user_can( 'activate_plugins' ) ) {
        $mimes['svg'] = 'image/svg+xml';
        return $mimes;
    }
}
add_filter( 'upload_mimes', 'file_mime_type' );

I'm guessing that WordPress is attempting to assign the SVG files a width and height. I didn't think that WordPress would try giving SVG files a width and height when publishing a post or page. Is there a way to exclude this from happening when publishing a post or page?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.