admin管理员组

文章数量:1133672

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?

本文标签: mediaUndefined array key quotwidthquot in wpadminincludesimagephp error when publishing post or page