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.

1 Answer 1


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;
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 );
  • Thanks that was quick! I forgot to mention: I have the SVG Plugin installed, but that did not change anything (I updated my initial question now). Probably some pretty important information, sorry! Question: Do I add this code to custom CSS oder functions.php? If the latter is necessary, I might have another problem because I cannot locate this file in the themes folder of the theme I currenty use. I tried other themes in the past and for some I see a folder structure with all files, for others I only see a link that seems to lead nowhere. How is that even possible?! May 17, 2021 at 8:20
  • You can try to deactivate SVG Plugin and paste code from my answer to your functions.php. At least will know if problem related to this plugin.
    – anton
    May 17, 2021 at 9:36
  • Will do. Thanks! May 17, 2021 at 9:58

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.