Make linking image to file more failsafe

Created on 30 October 2024, about 2 months ago

Problem/Motivation

Under certain circumstances, I get this error when trying to display a thumbnail through the formatter:

Error: Call to a member function getExternalUrl() on bool in Drupal\media_pdf_thumbnail\Plugin\Field\FieldFormatter\MediaPdfThumbnailImageFieldFormatter->viewElements() (line 267 in [Drupal root]/web/modules/contrib/media_pdf_thumbnail/src/Plugin/Field/FieldFormatter/MediaPdfThumbnailImageFieldFormatter.php)

This happens when $fieldInfos['image_uri'] does not exist (probably because the image generation was not successful).

Proposed resolution

A simple check for the existance of that key should be enough.

🐛 Bug report
Status

Active

Version

6.1

Component

User interface

Created by

🇩🇪Germany mrshowerman Munich

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024