-
AuthorPosts
-
July 16, 2014 at 12:00 pm #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 Imagethanks in advance
July 16, 2014 at 1:45 pm #292057i guess the problem is that wordpress (Media Library) did not recognize the size of the svg and sets it to 1 (width and height)
July 16, 2014 at 3:23 pm #292105Hi!
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!
DevinJuly 17, 2014 at 7:31 am #292369i 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
July 17, 2014 at 2:08 pm #292465Hi!
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!
IsmaelJuly 17, 2014 at 9:59 pm #292659no – 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 viewJuly 18, 2014 at 3:21 am #292780Were 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.
November 3, 2015 at 6:22 pm #529545Hello Guenni007,
Your code snippet in functions.php to upload and to use SVG-Images saved my day. Thanks for sharing!
TjerkNovember 4, 2015 at 9:12 am #529799October 9, 2018 at 10:38 pm #1019682Wish I could upvote this, Guenni007 your code also worked for me. Thank you for sharing!!
-
AuthorPosts
- You must be logged in to reply to this topic.