Problem/Motivation

Currently, the image_alt_fallback module is not compatible with Paragraph entities.

In these cases, content editors may need to mark images as decorative (which results in a role=“presentation” alt="" attribute for accessibility purposes).

Since paragraphs do not have titles or meaningful native tags like nodes do, the module currently does not allow them to be configured, which prevents the use of the decorative fallback in paragraph image fields—even though it would be a valid option for paragraphs.

Steps to reproduce the error

  1. Install and activate the image_alt_fallback and paragraphs modules.
  2. Go to the “Image ALT fallback” settings and note that there are no configurable options for Paragraphs.
  3. Create a “Paragraph” post type with an image field.
  4. Create a post, add the paragraph, upload an image, and leave the alt text field blank.
  5. View the generated page and inspect the image’s HTML code.
  6. Actual result: The empty decorative alt=“” is not applied.

Proposed resolution

Extend the module's compatibility to support Paragraph entities, specifically and exclusively for the "Decorative" fallback scenario.

Since Paragraphs lack traditional titles/labels, attempting to support the "Entity Label" fallback for them is not viable. Therefore, the backend logic and formatter settings should be updated so that when the host entity is a Paragraph, it successfully allows and applies the "Decorative" fallback, while safely ignoring (or disabling in the UI) the label fallback to ensure the feature remains stable.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

albeorte created an issue. See original summary.

albeorte’s picture

Status: Active » Needs review

Ready to check

omarlopesino’s picture

Status: Needs review » Needs work

I have added two points to the MR that should be addressed.

I think we can have a behaviour to get paragraph parent entity to get a label, see this comment: https://git.drupalcode.org/project/image_alt_fallback/-/merge_requests/5... . Let me know what do you think.

omarlopesino’s picture

Status: Needs work » Reviewed & tested by the community

After talking internally I have came to some conclusions about my review that I have resumed here and here.

It looks okay for me. I would like Alejandro to confirm.

omarlopesino’s picture

omarlopesino’s picture

Status: Reviewed & tested by the community » Fixed

Merged and released into 1.1.3. Thanks for the contribution!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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