Hello, I have altered the form for enabling SVG for image field and then focal point breaks the preview.
Modules used:
"drupal/focal_point": "1.0-beta4",
"drupal/crop": "1.2",
"acquia/lightning": "~2.1.0", (that downloads DRUPAL 8.3.3)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

seemas created an issue. See original summary.

seemas’s picture

Here is small fix (patch) for avoiding focal_point on svg files.

seemas’s picture

Small note how to apply using composer:
in composer.json

},
  "require": {
    "cweagans/composer-patches": "^1.6.0"
  }
  "extra": {
    "patches-file": "composer.patches.json",
    "composer-exit-on-patch-failure": true,
    "enable-patching": true
  }
}

in composer.patches.json

{
  "patches": {
    "drupal/focal_point": {
      "Fix for previewing SVG file": "https://www.drupal.org/files/issues/drupal8_3_3-focal_point-fix_preview_image_after_uploaded-2885249-1.patch"
    }
  }
}
kiwimind’s picture

Title: SVG file field preview with focal point (fixed) » SVG file field preview with focal point
Status: Active » Needs review

Status: Needs review » Needs work
bleen’s picture

+++ b/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php
@@ -40,7 +40,12 @@ class FocalPointImageWidget extends ImageWidget {
+    if (isset($element['preview']) && $file->getMimeType() != "image/svg+xml") {

wouldnt it be safer for this to be a positive check rather then negative? If mimetype == jpg, gif, bmp, webp, png ....

thoughts?

Anybody’s picture

Status: Needs work » Closed (duplicate)
Issue tags: -
Related issues: +#3122722: Allow SVG uploads in widget (svg_image compatibility)