When my field is empty, I've got this errors :
Notice : Undefined offset: 0 dans Drupal\image_popup\Plugin\Field\FieldFormatter\ImagePopupFieldFormatter->viewElements() (ligne 182 de /var/www/html/web/modules/contrib/image_popup/src/Plugin/Field/FieldFormatter/ImagePopupFieldFormatter.php).
Error: Call to a member function get() on null in Drupal\image_popup\Plugin\Field\FieldFormatter\ImagePopupFieldFormatter->viewElements() (line 182 of modules/contrib/image_popup/src/Plugin/Field/FieldFormatter/ImagePopupFieldFormatter.php).
And, of course, there are no errors when I upload one file or more.
So, when I checked the code, I saw there is no test at the line :
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = array();
$files = $this->getEntitiesToView($items, $langcode);
$image_style_popup = $this->getSetting('image_style_popup');
$image_style_name = $this->getSetting('image_style');
$image_fid = $files[0]->get('fid')->getValue()[0]['value'];
[...]
}
We just need to check if the size of the $items array parameters is not equal to zero and return an empty array.
Thank you for testing my patch.
Fixed
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.