SVG image field

Component ID

2863622

Component name

SVG image field

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

6891

Component created

Component changed

Component body

This module adds a new field, widget and formatter, which allows .svg file extension to be uploaded.

Module based on core Image and File modules and contrib svg_formatter. In formatter settings you can set default image size and enable alt and title attributes.

Requirements

Image is provided already by core [no dependencies].

Installation

  1. Install module as usual via Drupal UI, Drush or Composer.
  2. Go to "Extend" and enable the "SVG image field" module.

Using the Module

  1. Add "SVG Image" field to your Content Type or Taxonomy Vocabulary.
  2. Go to the "Manage display" → SVG Image Field Formatter settings and set image dimensions if you want and enable or disable attributes.

Similar projects and how they are different

svg_formatter:

  • There is no way to set custom alt on image because it uses file field. File field does not support alt on db level.
  • User must add svg extension at file field settings and select field formatter its not intuitive for user.
  • If user uploads non svg file it will break output.
  • if user uploads png and selects inline output at formatter settings it will break output
  • It not have preview image on file upload.
  • There is less ways what we can do with this all without breaking existiing installations

Module "SVG image field" does not have this weaks. You simply click "Add field", set field type to "Svg Image" and its done.

Author

shmel210
Drupal: https://www.drupal.org/u/shmel210
Email: shmel210@zina.com.ua