Exception thrown when no loading defined in OEmbedFormatter

Created on 26 October 2024, about 2 months ago

Problem/Motivation

If for some reason there is no loading option defined in admin/structure/media/manage/remote_video/display/some_display_mode, then we have an exception because of the call of $this->getSetting('loading')['attribute'].
No more possible to access the media view mode settings page.

Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter->settingsSummary() line 328

    $summary[] = $this->t('Loading attribute: @attribute', [
      '@attribute' => $this->getSetting('loading')['attribute'],
    ]);

and line 289

     '#default_value' => $this->getSetting('loading')['attribute'],

Steps to reproduce

No idea how I came with a view mode with no loading option

Proposed resolution

Commenting out the above lines I was able to access the view mode page and set max_width, max_height and loading option to 'lazy'. Then everything worked as expected and I could access the settings page even after uncommented the above lines.
Perhaps do a test if 'loading' is set before calling $this->getSetting('loading')['attribute']

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.4

Component

media system

Created by

🇫🇷France erwangel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @erwangel
  • 🇮🇳India junaidpv Kannur, Kerala

    I also facing this issue.
    In my case it was already using "Blazy OEmbed" (from the blazy module) which has a string setting 'loading'. So, switching to "oEmbed content" formatter causes the error.

    A fix worked for me was to replace occurrences of $this->getSetting('loading')['attribute'] with $this->getSetting('loading')['attribute'] ?? NULL.

  • 🇳🇿New Zealand quietone

    Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

Production build 0.71.5 2024