Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #292012

    to upload and to use SVG-Images in WordPress is done by this code in the functions.php e.g.:

    function custom_mtypes( $m ){
        $m['svg'] = 'image/svg+xml';
        $m['svgz'] = 'image/svg+xml';
        return $m;
    add_filter( 'upload_mimes', 'custom_mtypes' );

    but the thing is that in Media-Library the tumnails are not shown!
    And the most ugly problem is that you can’t use them as featured image.

    i found a hint on :

    but it does’t work for the featured image (even if i change the dimensions to 180×180 (i guess this is the dimension of enfold thumbnails))

    Can you help?
    How to use svgs as featured Image

    thanks in advance


    i guess the problem is that wordpress (Media Library) did not recognize the size of the svg and sets it to 1 (width and height)



    You can see if it will work with one of the default twenty___ themes. Enfold shouldn’t have any conflicts since its using the same WordPress functions but that way you can eliminate the theme variable when testing out adding the new functionality to WordPress.



    i have no conflicts with uploading them – and even the usage as logo works – but

    a) i have no thumbnails in Medialibrary List (this is good solved by the link above ) in functions.php

    function custom_admin_head() {
      $css = '';
      $css = ' img[src$=".svg"] { width: 100% !important; height: auto !important; }';
      echo '<style type="text/css">'.$css.'</style>';
    add_action('admin_head', 'custom_admin_head');

    b) i cant use it as featured image

    i didn’t find anything in the web to solve this – i think i had to make it through a png fallback



    Thank you for using the theme.

    After you’ve added the featured image, add this on Quick CSS:

    img.wp-post-image {
    min-width: 100% !important;



    no – this will have the effect:
    it seems not to be a trivial problem.
    i achieved it that on post edit the thumbnail is shown on picture 3 – but it won’t show the featured image in category view


    Were you able to test this on any of the default themes? I’m just not sure this is something we can bug fix as WordPress doesn’t have support for it right now.


    Hello Guenni007,
    Your code snippet in functions.php to upload and to use SVG-Images saved my day. Thanks for sharing!


    Hi Tjerk,

    Glad it was of use to you :-)

    Best regards,


    Wish I could upvote this, Guenni007 your code also worked for me. Thank you for sharing!!

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.