Problem/Motivation
The image theme function requires an array for the attributes variable:
'image' => [
'variables' => ['uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => [], 'sizes' => NULL, 'srcset' => [], 'style_name' => NULL],
],
But template_preprocess_image_formatter
uses its item attributes for the image render array:
function template_preprocess_image_formatter(&$variables) {
//...
$variables['image']['#attributes'] = $variables['item_attributes'];
//...
}
According to the theme definition these can be NULL, which is not valid:
function image_theme() {
return [
//...
'image_formatter' => [
'variables' => ['item' => NULL, 'item_attributes' => NULL, 'url' => NULL, 'image_style' => NULL],
'file' => 'image.field.inc',
],
];
}
Proposed resolution
Cast the attributes to an array in template_preprocess_image_formatter
.