Allow SVG uploads in widget (svg_image compatibility)

Created on 26 March 2020, over 4 years ago
Updated 8 May 2024, 8 months ago

Though obviously SVG images can't be cropped the way other mimetypes are, it'd still be nice to allow their upload with the Focal Point widget.

I'm using https://www.drupal.org/project/svg_image β†’ which allows SVG images in core's image widget.

  • With the "Image (Focal Point)" widget, I can't upload an SVG ("Only files with the following extensions are allowed...").
  • If I change the field widget to core's "Image" widget, I can upload SVG files.
  • I can then change the widget back to the "Image (Focal Point)" widget, and there are no problems with the SVG I'd uploaded: I can see it in my Media admin listing; I can see it in the Media library; I can use it on a page and it looks totally fine; I can even edit the Media entity and replace the SVG file.

I'm hoping it would be a really simple fix to allow the mimetype to be uploaded even if SVGs can't take advantage of any of Focal Point's awesomeness.

Thanks!

✨ Feature request
Status

Postponed

Version

2.0

Component

Other Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Kasey_MK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΉAustria hudri Austria

    I don't think comment #24 covers the root problem: Do we need to inherit from the core image module or from the svg_image module? Creating a base widget surely is a good idea, but it just move the same problem to a different file.

    But I think I've found the proper way to dynamically react on the existance of the svg_image module: hook_element_plugin_alter ( change record β†’ , API doc)

    It was explicitly designed to change the plugin class on runtime, exactly what is needed here. However, I still think we should wait for the other issue with the standalone form element.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 5.7
    last update 11 months ago
    Patch Failed to Apply
  • πŸ‡ΈπŸ‡¦Saudi Arabia mesharideb

    This patch enhances the Drupal Focal Point module to handle SVG images. It introduces a dependency on the SVG Image module and modifies the FocalPointImageWidget to extend from SvgImageWidget instead of ImageWidget. Additionally, it adds a condition to check if the image is an SVG. If it is, the function returns an empty array, bypassing the focal point functionality which is not applicable to SVG images.

  • πŸ‡¨πŸ‡ΏCzech Republic milos.kroulik

    Unfortunately, the patch from #27 doesn't seem to be working for me, as the "sub-widget" still doesn't allow SVG.

  • πŸ‡¨πŸ‡¦Canada SKAUGHT

    IMO: this should be at least it's own submodule to focal_point, it not it's own project. the dependency to svg_field is heavy, forces every site to now use another module even if they don't 'need svg' at this time.
    Certainly, would be nice if Drupal Core had an SVG solution in place to work with.

  • miiimooo Europe

    Adding a re-roll of the patch in #13 for 2.1.0

    The patch in #27 adds some check which is not part of this patch

Production build 0.71.5 2024