Allow empty alt text on images

Created on 9 April 2024, 6 months ago

Problem/Motivation

I need to support an empty alt attribute on images. Looking at the code (and error message after leaving the required alt field blank) it says to enter two double-quotes. This does not work for me.

When I double-click the image in CKE4 to edit the attributes, it defaults to the value from the image as expected. Then if I enter "" for the alt text and click the "Embed" button, looking at Source mode I can see the alt attribute is not there, as expected. But when I double-click the image again to edit it, the alt text is defaulted back to the alt attribute from the image; doesn't preserve the empty value. With the current setup, there is no way for a user to add an empty alt attribute to an image.

The issue appears to be the submitConfigurationForm() method on the ImageFieldFormatter class. It looks for the double-quotes in the alt field, and replaces it with an empty string. This does not allow the other logic to find the double-quotes to keep an empty alt value.

🐛 Bug report
Status

Active

Version

1.6

Component

Miscellaneous

Created by

🇨🇦Canada smulvih2 Canada 🍁

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

Comments & Activities

  • Issue created by @smulvih2
  • 🇨🇦Canada smulvih2 Canada 🍁

    Patch attached removes the submit logic and now I can successfully add an empty alt value, and it gets carried over to the node view as expected.

Production build 0.71.5 2024