SVG upload does not work

I have created an SVG with clickable areas to be used as landing page image, The size of the file is 4 MB. I cannot upload it, Wordpess says there is an error (no specifics). Size seems not to be the problem, other files of this size are uploaded.

I have the SVG Support plugin installed.

I used lnkscape to create it. It looks fine in Edge and does what it is supposed to. I tried all SVG formats that are available in lnkscape but all fail.

I do not use Media Library Assistant.

Where could I start looking what the problem is?

Could the theme I use be the problem (Thefour)?

Bear with me if this is really trivial - I am very new to this.

Topic svg uploads Wordpress

Category Web


Wordpress doesn't allow to upload SVG files by default.

Add svg file type in allowed file types list

function wp_mime_types($mimes)
{
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter('upload_mimes', 'wp_mime_types');

Fix for displaying svg files in media library

function wp_fix_svg() {
    echo '<style type="text/css">
        .attachment-266x266, .thumbnail img {
         width: 100% !important;
         height: auto !important;
        }
        </style>';
}
add_action( 'admin_head', 'wp_fix_svg' );

Attempt to determine the real file type of a file

function wp_check_filetype($data, $file, $filename, $mimes) 
{
    global $wp_version;
    if( $wp_version !== '4.7.1' ){
        return $data;
    }

    $filetype = wp_check_filetype( $filename, $mimes );

    return [
        'ext'             => $filetype['ext'],
        'type'            => $filetype['type'],
        'proper_filename' => $data['proper_filename']
    ];
}
add_filter( 'wp_check_filetype_and_ext', 'wp_check_filetype', 10, 4 );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.