Hi Team,

I install Media Module(core module) to upload image for drupal 8 based Website. While uploading svg image I am getting error.
Please find the attached screenshot(Untitled.png).

Please let me know, How to use Media Module for svg Image.

Thanks

CommentFileSizeAuthor
Untitled.png36.86 KBnikkitam

Comments

nikkitam created an issue. See original summary.

nikkitam’s picture

Priority: Major » Critical
babusaheb.vikas’s picture

For uploading .svg image you need to install svg_insert and svg_image module.
Please check the link for these modules:-
https://github.com/58bits/insert_svg
https://www.drupal.org/project/svg_image

## Installation
1. Download and enable the module as usual.
2. Go to your filters admin (admin/config/content/formats).
3. Edit the format on which you want to enable the insertion of SVGs.
4. Drag the 'S' icon to the "Active toolbar".
5. Configure the plugin settings in the vertical tabs above the toolbar
Save.

babusaheb.vikas’s picture

Status: Active » Needs review
lukus’s picture

Related issues: +#3043000: Media support
lukus’s picture

I've installed the svg_image module, but it doesn't seem to function correctly with media.

joseph.olstad’s picture

Project: D7 Media » Drupal core
Version: 8.x-1.x-dev » 8.7.x-dev
Component: Media Field » media system
cilefen’s picture

Title: Is Media Module Support SVG Image in Drupal 8 » Does the Media Module Support SVG Images?

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jwilson3’s picture

At this point, there are several contrib modules that provide SVG capabilities, so it is hard to know what combination of them works. Below is my preferred recipe, but if you're still on the fence about how to choose the right SVG media module from Drupal 8 contrib, you may find my comparison of the 3 modules helpful to guide your decision making: https://drupal.stackexchange.com/a/280837/3167

This is my recipe that works with Media in Core, and leverages SVG Image Field (copied from https://drupal.stackexchange.com/a/280836/3167)

  1. Enable Media module and the experimental Media Library module both of which are found in Drupal >=8.7 core.
  2. Download and enable SVG Image Field and apply to it the patch from #3053011: Support Media Library.
  3. Go to /admin/structure/media and click the "Add Media Type" button.
  4. For the Media Type Name specify 'SVG'.
  5. For the Media source select SVG from the dropdown.
  6. In the field mappings map Name to Name (the only option in the dropdown).
  7. Click save. Then proceed to configure the Form Display and the Display for the Default and Media Library view mode at /admin/structure/media/manage/svg/form-display and /admin/structure/media/manage/svg/display respectively. You'll most likely want to just enable the "SVG" field, and disable the rest of the fields. The default display you can choose to use an inline SVG option.
  8. Add a Media reference (Entity reference) field to your node types and configure it to allow the SVG bundle type. Optionally, enable other bundle types as well, like Image if you want to allow both images and SVGs in the same slot).
  9. Go create a node, and click the "Add media" link.
  10. Notice that the Media Library loads with a vertical tab for each kind of media type bundle you enabled in step 8 on your node configuration screen.
feuerwagen’s picture

Priority: Critical » Normal
joseph.olstad’s picture

There is a contrib module to help with svg images, a new release today.
https://www.drupal.org/project/svg_image

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

phenaproxima’s picture

Component: media system » image system
Status: Needs review » Closed (works as designed)
Issue tags: +svg, +Triaged Media Initiative issue

The Media module itself has no opinion about SVG images. The Image module, on the other hand, doesn't normally allow SVG to be uploaded into any image field, due to the various security and integration issues (i.e., image styles). This is the case regardless of whether the media system is in use.

The SVG Image module does seem to be a good solution here. Getting SVG support into core's image system would be outside the scope of the Media module right now.

I think that, given all these things (and the fact that other issues exist to add SVG support to core), I'm closing this as "works as designed".