Image media field has no license but author/source name is present.

Created on 9 December 2022, over 2 years ago
Updated 24 September 2023, over 1 year ago

Problem/Motivation

If image field (media__field_media_attribution) has author name or source name but has no license then this will causes the following error
Error: Call to a member function getId() on null in Drupal\attribution\Plugin\Field\FieldFormatter\AttributionCreativeCommonsRefinedFormatter->viewElements() (line 39 of modules/contrib/attribution/src/Plugin/Field/FieldFormatter/AttributionCreativeCommonsRefinedFormatter.php).

Steps to reproduce

  1. Add image
  2. Add attribution "Author" but leave "License" empty
  3. Create basic page
  4. In the Body using WYSIWYG media button insert the image

Proposed resolution

Adding simple check should fix the issue.
if ($values['license'])

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇦Canada jinah2020

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.

Production build 0.71.5 2024