Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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 : http://css-tricks.com/snippets/wordpress/allow-svg-through-wordpress-media-uploader/

    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

    #292057

    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)

    #292105

    Hi!

    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.

    Cheers!
    Devin

    #292369

    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 http://css-tricks.com/snippets/wordpress/allow-svg-through-wordpress-media-uploader/ ) in functions.php

    function custom_admin_head() {
      $css = '';
      $css = 'td.media-icon 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

    #292465

    Hi!

    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;
    }

    Cheers!
    Ismael

    #292659

    no – this will have the effect:
    http://abload.de/img/017wjad.jpg
    http://abload.de/img/02xnkc0.jpg
    http://abload.de/img/03cikgg.jpg
    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

    #292780

    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.

    #529545

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

    #529799

    Hi Tjerk,

    Glad it was of use to you :-)

    Best regards,
    Rikard

    #1019682

    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.