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
- Install and activate the
image_alt_fallbackandparagraphsmodules. - Go to the “Image ALT fallback” settings and note that there are no configurable options for Paragraphs.
- Create a “Paragraph” post type with an image field.
- Create a post, add the paragraph, upload an image, and leave the alt text field blank.
- View the generated page and inspect the image’s HTML code.
- 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.
Issue fork image_alt_fallback-3608594
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
Comment #3
albeorte commentedReady to check
Comment #4
omarlopesinoI 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.
Comment #5
omarlopesinoAfter 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.
Comment #6
omarlopesinoBy reviewing this task I've noticed that we can improve the module with these issues:
Comment #8
omarlopesinoMerged and released into 1.1.3. Thanks for the contribution!