R
R
Ratatat2014-11-01 21:58:24
Design
Ratatat, 2014-11-01 21:58:24

How to add SVG support to WordPress?

Hello!
Please tell me how to add SVG support to WordPress. For example, so that I can upload an SVG and then add it to the article in the same way as regular photos.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Antony Bark, 2015-08-20
@tolfy

In the admin menu:
> Appearance
> Editor
> Edit Themes
> "Your Theme": Theme Functions (functions.php)
Add lines:

// allow SVG uploads
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
  $existing_mimes['svg'] = 'image/svg+xml';
  return $existing_mimes;
}
function fix_svg() {
    echo '<style type="text/css">
          .attachment-266x266, .thumbnail img {
               width: 100% !important;
               height: auto !important;
          }
          </style>';
 }
 add_action('admin_head', 'fix_svg');

Don't forget to unprotect the functions.php file
read more css-tricks.com/snippets/wordpress/allow-svg-throug...

B
bert19, 2019-01-10
@bert19

Saved! Just saved!
The fact is that after they "killed" flash - it seemed that everything - 7 years of practice down the drain!
And here svg & Adobe Animate to boot. And the nasty Wp won't let me load my svg's.
The only thing that is not entirely clear: to remove the protection in the file via ftp with chmod? And then wp itself writes the file type successfully updated.
Okay, I'll figure it out.
Thanks again!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question