Error when using Base64 Encoded Image formatter with Drupal core 9.4.5

Created on 6 September 2022, over 2 years ago
Updated 5 July 2023, almost 2 years ago

Problem/Motivation

We're using the Base64 Encoded Image formatter for media images displayed in generated PDFs. With the 9.4.x versions of Drupal core that added the loading attribute, the lack of settingsSummary() implementation in Base64ImageFormatter.php is causing the following error:

Notice: Trying to access array offset on value of type null in Drupal\image\Plugin\Field\FieldFormatter\ImageFormatter->settingsSummary() (line 210 of /var/www/html/web/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php)

Steps to reproduce

Install media on Drupal 9.4.5 with a configured image media type that has a view mode using the Base 64 Encoded Image formatter and view the "Manage display" tab for that formatter.

Proposed resolution

This problem is avoided by implementing the settingsSummary() function in Base64ImageFormatter.php

Patch forthcoming.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jastraat

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States alexandersluiter

    This just happened to me as well. I believe #8 to be a correct assumption. Adding + parent::defaultSettings() to public static function defaultSettings() fixes the issue as well, though the patch above may be the better route since the default image settings are irrelevant to the Base64 formatter.

Production build 0.71.5 2024