Needs work
Project:
Drupal core
Version:
main
Component:
image.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
14 Mar 2021 at 14:27 UTC
Updated:
21 Aug 2025 at 11:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
nikhil banait commentedAdded a configuration to the image field setting.

Comment #4
vakulrai commentedPatch from #2 is working and applied cleanly. But is a scenario which I think is valid :
BY default on creating a new image field the "Alt text held is required" which if we let as its and "'Set uploaded filename as default Alternative text" is checked, the user can still overwrite the behaviour of the patch from the node page check: Filed-with-alt-required.png.
Now the scenario becomes "set default filename as text " with overwriting it from node form.
Added Code to prevent this behaviour: Now if while creating the image field "'Set uploaded filename as default Alternative text" input is Checked then required alt text filed will become unrequired: Field-state-change.png
Comment #5
vakulrai commentedFixed Some Code Standards Issue .
Comment #7
nikhil banait commented@vakulrai Thanks for updating the patch. I would recommend to remove the changes regarding making 'Alt field required' unchecked when 'Set uploaded filename as default Alternative text' is checked. Actually setting up default value & making any field required are two different concepts. However default value is supposed to be changed by editor always. For good SEO, these fields(alt & title) has to be mandatory. It's upto an editor to override default value or not.
I hope you understand my view.
Comment #11
tommiecrawford commentedPatch #2 and #5 didn't worked for me, recreated it.
Comment #12
tommiecrawford commentedFix typo and set default values.
Comment #14
mhmhartman commentedRecreated the patch for Drupal 9.5.1
Comment #15
_utsavsharma commentedTried to fix CCF for #14.
Comment #16
_utsavsharma commentedComment #19
aitala commentedThere is an issue with this patch when you are uploading multiple images into a field.
All the images get Alt text from the first image name.
This is with Drupal 9.5.10 and the Plupload Integration Module with unlimited number of images. Note that I don't think plupload is being used for the image field here.
Thanks,
Eric
Comment #20
aitala commentedAdding an attachment...
Comment #21
dgsiegel commentedAs this patch didn't work for us in Drupal 10.x, we've decided to handle this in a custom module. We're appending a custom callback in the widget hook for
image_imageand setting the default value of the alt tag there:Hope this helps!
Comment #22
charles belovAdding accessibility and needs accessibility review tags. In my experience, file names are typically not appropriate as alt text.
Comment #27
charles belovHas an accessibility review been done on this issue?
Comment #28
falcon03 commentedThe strongest possible -1 from an accessibility standpoint. This feature would encourage a bad practice that unfortunately is very popular on the Internet.
Comment #29
charles belovNoting that the filename coming from an iPhone is typically just IMG followed by a sequence number, something that is not accessible. I also see many image file names on our website that are gibberish.
Comment #30
calydia commentedAs people above have already commented, this would be bad for accessibility. The purpose of the alt text is to describe the image, which a filename in most cases just doesn't do.
Comment #31
bohus ulrychMy two cents - for me this is nice feature. My files (filenames) are already well organized with proper names and generate alt from the filename save my time.
FYI #21 patch works - but only with one file. For all other alts it always use alt from the first image.