Skip to content
Snippets Groups Projects

created mr based on last patch and fix linting issues

Open Rajneesh Babu requested to merge issue/drupal-2949573:2949573-call-to-a into 11.x
2 unresolved threads
@@ -26,6 +26,9 @@
'image',
],
)]
/**
* Defines the image formatter for rendering image fields.
*/
class ImageFormatter extends ImageFormatterBase {
/**
@@ -238,7 +241,28 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$base_cache_tags = [];
if (!empty($image_style_setting)) {
$image_style = $this->imageStyleStorage->load($image_style_setting);
$base_cache_tags = $image_style->getCacheTags();
if (!empty($image_style)) {
$base_cache_tags = $image_style->getCacheTags();
}
else {
$fieldDefinitionForMessage = $items->getFieldDefinition();
$message = $this->t('The image style of %field field is broken on the %entity bundle %bundle.%extraNodeMessage', [
'%field' => $fieldDefinitionForMessage->getName(),
'%entity' => $fieldDefinitionForMessage->getTargetEntityTypeId(),
'%bundle' => $fieldDefinitionForMessage->getTargetBundle(),
'%extraNodeMessage' => $fieldDefinitionForMessage->getTargetEntityTypeId() == 'node'
? "\nTry (re)setting the image style in the display settings and form display settings."
: '',
]);
\Drupal::messenger()->addError($message);
Please register or sign in to reply
return [
'#type' => 'markup',
'#markup' => '<pre>' . $message . '</pre>',
'#cache' => [
'max-age' => 0,
],
];
    • Comment on lines +258 to +264

      We could simply return the image without an image style here, like no image stile was selected. I think for visitors this would be less dramatic?

Please register or sign in to reply
}
}
foreach ($files as $delta => $file) {
Loading