@@ -233,8 +233,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
233233 // yet.
234234 // @see https://github.com/esmero/format_strawberry/issues/1
235235
236- //@ TODO recheck cache tags here, since we are not really using
237- // the file itself.
238236 $ iiifpublicinfojson = $ iiifhelper ->getPublicInfoJson ($ iiifidentifier );
239237
240238 $ groupid = 'iiif- ' . $ items ->getName () . '- ' . $ nodeuuid . '- ' . $ delta . '-media ' ;
@@ -254,6 +252,11 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
254252 'data-iiif-thumbnails ' => $ thumbnails ,
255253 'style ' => "width: {$ max_width_css }; height: {$ max_height }px " ,
256254 ],
255+ //@ TODO recheck cache tags here, since we are not really using
256+ // the file itself.
257+ '#cache ' => [
258+ 'tags ' => $ file ->getCacheTags (),
259+ ],
257260 ];
258261 if (isset ($ item ->_attributes )) {
259262 $ elements [$ delta ] += ['#attributes ' => []];
@@ -291,7 +294,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
291294 // This also never runs if cached. So after deletion we better
292295 // call the controller!
293296 if (!empty ($ jsondata ['ap:annotationCollection ' ]) && is_array ($ jsondata ['ap:annotationCollection ' ])) {
294- WebAnnotationController::primeKeyStore ($ items [$ delta ]);
297+ $ keystoreid = $ elements [$ delta ]['media ' . $ i ]['#attached ' ]['drupalSettings ' ]['format_strawberryfield ' ]['openseadragon ' ][$ uniqueid ]['keystoreid ' ];
298+ WebAnnotationController::primeKeyStore ($ keystoreid );
295299 }
296300 }
297301 if ($ this ->currentUser ) {
0 commit comments