From 6234d1a48741bca232b2e368478121008483fe1c Mon Sep 17 00:00:00 2001 From: Chi Date: Sun, 23 Jun 2019 14:59:25 +0500 Subject: [PATCH] Trigger error when image style does not exist --- src/TwigExtension.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/TwigExtension.php b/src/TwigExtension.php index a1a2c1a..74d1e91 100644 --- a/src/TwigExtension.php +++ b/src/TwigExtension.php @@ -630,15 +630,18 @@ class TwigExtension extends \Twig_Extension { * @param string $style * The image style. * - * @return string + * @return string|null * The absolute URL where a style image can be downloaded, suitable for use * in an tag. Requesting the URL will cause the image to be created. */ public function imageStyle($path, $style) { - /** @var \Drupal\Image\ImageStyleInterface $image_style */ if ($image_style = ImageStyle::load($style)) { return file_url_transform_relative($image_style->buildUrl($path)); } + else { + // @todo Throw an exception int 3.x. + trigger_error(sprintf('Could not load image style %s.', $style)); + } } /**