Warning rying to access array offset on value of type null in Drupal\media_responsive_thumbnail\Plugin\Field\FieldFormatter\MediaResponsiveThumbnailFormatter->viewElements()After updating from 8.x-1.2 to 8.x-1.3

Created on 16 February 2023, almost 2 years ago
Updated 19 June 2023, over 1 year ago

Problem/Motivation

after updating from 1.2 to 1.3,
i receive lots of warnings
Message Warning : Trying to access array offset on value of type null in Drupal\media_responsive_thumbnail\Plugin\Field\FieldFormatter\MediaResponsiveThumbnailFormatter->viewElements() (/var/www/html/web/modules/contrib/media_responsive_thumbnail/src/Plugin/Field/FieldFormatter/MediaResponsiveThumbnailFormatter.php line 164)

Steps to reproduce

Update to 1.3, visit a page with images rendered as responsive thumbnail.

Proposed resolution

It seems to be caused by
this commit https://git.drupalcode.org/project/media_responsive_thumbnail/-/commit/4...
from https://www.drupal.org/project/media_responsive_thumbnail/issues/3341959 πŸ“Œ Update code based on recent changes to ResponsiveImageFormatter Fixed
that doesn't check if the attribute exists.
As far as i can tell responsive thumbnail formatter doesn't expose loading attribute option so it seems logical that it's null.

πŸ› Bug report
Status

Fixed

Version

1.3

Component

Code

Created by

πŸ‡«πŸ‡·France ericdsd France

Live updates comments and jobs are added and updated live.
  • Regression

    It restores functionality that was present in earlier versions.

Sign in to follow issues

Comments & Activities

  • Issue created by @ericdsd
  • πŸ‡«πŸ‡·France ericdsd France
  • πŸ‡©πŸ‡ͺGermany yoruvo Stuttgart

    Looks like the lazy image loading stuff was only added in 10.1.x, so my mistake was applying the fix from #3322231 without specifying the different version required.

    • yoruvo β†’ authored bfa1bc35 on 8.x-1.x
      Issue #3342428 by yoruvo: Warning rying to access array offset on value...
  • πŸ‡©πŸ‡ͺGermany yoruvo Stuttgart

    Could you check out the newest dev branch and report if that fixes it? If so, I can push the next release.

  • πŸ‡§πŸ‡ͺBelgium adiatis Belgium

    dev branch solves the problem. Can you push to next release?

    Thx

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

    The dev branch did not solve this issue for us on Drupal 9.5. We had to revert back to 1.2.

    Here are the logs:

    Message Deprecated function: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in Drupal\image\Entity\ImageStyle->addExtension() (line 505 of /sites/dev/cms/releases/20230222200847/web/core/modules/image/src/Entity/ImageStyle.php)

    Deprecated function: pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated in _responsive_image_build_source_attributes() (line 380 of /sites/dev/cms/releases/20230222200847/web/core/modules/responsive_image/responsive_image.module)

    Could not determine image width for '' using image style with ID: 1024. This image style can not be used for a responsive image style mapping using the 'sizes' attribute.

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

    The dev branch worked for us on Drupal 9.5.3. Just to be completely sure, after I installed the dev version of the module, I rebuilt caches via drush and rechecked the page where I saw the warning. The warning didn't appear, and I didn't see anything in the logs or status report page.

  • πŸ‡©πŸ‡ͺGermany yoruvo Stuttgart
  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany yoruvo Stuttgart

    I suppose I'll consider this fixed, since #7 looks unrelated.

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

    @yoruvo I am still trying to debug this. Something has changed in the output which causes issues in Drupal 9.5.3.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed over 1 year ago
  • πŸ‡«πŸ‡·France ericdsd France

    Hi Yoruvo,
    the issue by itself is indeed fixed, but it would be nice to provide a setting in media_responsive_thumbnail formatter to manage loading attribute.
    Should i create a feature request for that ?

Production build 0.71.5 2024