Commit 9a4c8b08 authored by catch's avatar catch
Browse files

Issue #3307409 by mherchel, heddn, gquisini, Phoenixbros, bbu23: Setting media...

Issue #3307409 by mherchel, heddn, gquisini, Phoenixbros, bbu23: Setting media field to loading="eager" doesn’t work when using the media_thumbnail field formatter

(cherry picked from commit 0687f85d)
parent 8dd02e19
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -157,7 +157,9 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
      $elements[$delta] = [
        '#theme' => 'image_formatter',
        '#item' => $media->get('thumbnail')->first(),
        '#item_attributes' => [],
        '#item_attributes' => [
          'loading' => $this->getSetting('image_loading')['attribute'],
        ],
        '#image_style' => $this->getSetting('image_style'),
        '#url' => $this->getMediaThumbnailUrl($media, $items->getEntity()),
      ];
+2 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ public function testRender() {

    // Validate image being loaded with the content on the link.
    $this->assertSession()->responseContains('<a href="' . $node->toUrl()->toString());
    $this->assertSession()->responseContains('loading="eager"');
  }

  /**
@@ -122,6 +123,7 @@ private function changeMediaReferenceFieldLinkType(string $type): void {
        'settings' => [
          'image_link' => $type,
          'image_style' => '',
          'image_loading' => ['attribute' => 'eager'],
        ],
      ])
      ->save();