From 5372b821b2980c27d9df126ce74a83313f50ba6d Mon Sep 17 00:00:00 2001 From: Chi Date: Wed, 10 Jul 2019 18:18:55 +0500 Subject: [PATCH] Issue #3053556 by phjou: image_style doesn't support SVG --- src/TwigExtension.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/TwigExtension.php b/src/TwigExtension.php index 0d88b29..874d314 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -829,12 +829,18 @@ class TwigExtension extends \Twig_Extension { * in an tag. Requesting the URL will cause the image to be created. */ public function imageStyle($path, $style) { - if ($image_style = ImageStyle::load($style)) { - return file_url_transform_relative($image_style->buildUrl($path)); - } - else { + + if (!$image_style = ImageStyle::load($style)) { trigger_error(sprintf('Could not load image style %s.', $style)); + return; } + + if (!$image_style->supportsUri($path)) { + trigger_error(sprintf('Could not apply image style %s.', $style)); + return; + } + + return file_url_transform_relative($image_style->buildUrl($path)); } /**