我有一个问题:我的小枝模板正在计算图像样式,但没有应用它。
news.html.twig中的代码
<img class="emphasized" src="{{ field_news_emphasized|image_style('emphasized_image') }}" alt="{{ field_news_emphasized.alt }}"/>field_news_emphasized = public://2019-07/img.jpg
这个图像看起来很好,因为我想用图像样式emphasized_image计算它,但是我仍然有一个警告Debug: Could not apply image style emphasized_image. in Drupal\twig_tweak\TwigExtension->imageStyle() (line 843 of modules\contrib\twig_tweak\src\TwigExtension.php).。
在TwigExtension.php的第843行下面是:
if (!$image_style->supportsUri($path)) {
trigger_error(sprintf('Could not apply image style %s.', $style));
return;
}我怎样才能修正这个警告?
发布于 2019-08-07 07:42:55
问题解决了--我试图在两种情况下应用图像样式,在这两种情况下,我没有加载img (这是一个数组:存在,空,空,存在)。
{% if field_news_emphasized != NULL %}解决了这个问题。
https://stackoverflow.com/questions/57388791
复制相似问题