Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
image.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Jun 2010 at 17:31 UTC
Updated:
9 Mar 2015 at 09:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
quicksketchOne of these modules may help with this request:
http://drupal.org/project/imagefield_extended
http://drupal.org/project/filefield_uiextras
ImageField does not include this functionality. Since ImageField has been moved into Drupal 7 core (as Image module), we can't add new features to ImageField in Drupal 6, so it will need to be provided by an add-on module either way.
Comment #2
quicksketchComment #3
jenlamptonGovernment and Educational institutions, in particular, care a lot about accessibility. They continue to request a way to make the custom ALT text field required so that content creators can not submit a node form without ALT text for all images.
Neither of the two modules recommended above will solve that exact problem. My suggestion so far has been to create a custom module that alters the node forms that contain image fields, and force the field to be required. But I haven't yet found a solution that doesn't require custom code.
What I'd prefer to see:
1) an additional checkbox on the edit field settings page for "Require ALT text" (see image_alt_field.png)
and if the box is checked...
2a) if an image is selected and a user hits "Upload" the ALT text field that appears is now required (see img_alt_required.png)
2b) if an image is selected and a user hits "Save" instead of "Upload" the image is uploaded, but the form fails validation, and requires that the ALT text be added (see img_alt_req_fail.png)
Comment #4
damien tournoud commentedI'd definitely support this, but it is a feature request.
For Drupal 7, it's would be fairly easy to provide this as a contribution module.
Comment #5
mgiffordI agree that this needs help. It's great that images support is in core, but it could be done a lot better for accessibility.
I've added some screenshots for how it is in D7. Hopefully we can use hooks in core to implement a best case solution with the help of the http://drupal.org/project/accessible module.
EDIT: Worth also looking at this thread from the ImageField module's issue queue.
Also worth noting that putting in just anything into an alt text should produce an error. An alt text should never be the same as a file name. Spaces should be considered the same as empty. There should be room for acceptable tags for placeholders like 'spacer' or 'blank' as often images are used just to manage positioning.
Use of identical title & alt attributes can also cause problems [520704] - some screen readers read out both.
Comment #6
quicksketchAs in the ImageField queue, I think we need to balance the accessibility-friendly with usability-friendly options. If you start giving users errors that their ALT text is required, and then another error that the alt text isn't "good enough", people aren't going to like creating content in Drupal. IMO, such frustrations should be kept to contrib, even in Drupal 8.
Comment #7
mgiffordMight make sense to leave it in contrib. Possibly that level of validation could be done through jQuery so that the user could be better guided to provide a good alt tag. In many ways it's really not all that easy though. Content creators can benefit from being prompted about what makes a good alt tag for an image. A government or university department may need for there to be stricter policies.
But yes, certainly all things to consider and implement as resources & inspiration allows.
Comment #8
jenlamptonWhat about a "require alt text" option, that is by off default?
Comment #9
mgiffordwhy off by default?
Comment #10
jenlamptonSo people keep enjoying creating content in Drupal :)
Comment #11
Everett Zufelt commentedI do think that when creating an image field that there should be an option for requiring alt text, however, I do agree that it should be off by default.
1. Administrators might not understand the option, in which case off is the best choice for them (when they begin to experience problems they won't understand why.
2. Administrators that know that they want the option can turn it on
Comment #12
mgiffordPerhaps could we strive to have a message pop up to warn folks that they've added an image without an alt tag by default? Not a error that would stop them from uploading the page, but something which clearly lets them know that it is an issue.
Maybe this warning message would probably need to be configured to be turned off too. I'm just afraid that with the status quo, we're not going to change content administrator's behaviors.
Comment #13
Everett Zufelt commentedPerhpas we need better description / help text for the image field widget?
Comment #14
mgiffordTies into documentation here - http://drupal.org/documentation/modules/image
Comment #15
quiptime commentedDrupal 7:
To make required the Alt field of a image field it is possible to use the EIM module.
Comment #16
mgiffordNeat. Will have to look at that and add it to the docs! Thanks Quiptime.
Comment #17
jenlampton@mgifford I don't think an error message is necessary (and in fact, I think it would be overkill for most drupal sites) If the alt field is enabled, people will be encouraged to use it. If the field is required - then an error message will appear to content creators when it is left empty. I think site builders will mostly want to leave the field optional - except when accessibility is a requirement.
I've also been toying with the idea of an accessibility module that would set a bunch of important defaults for you - things like this - it could strongarm into place so that they can't be overlooked by site builders.
Comment #18
mgifford@jenlampton - What I'm interested in is how to gently alter people's behaviour. A reminder that they've added an image without an alt tag may be all that's required. I agree that you would want to have an admin setting or additional module that steps this up so that you could actually force users to insert a meaningful alt text (not - "image" or "file123.jpg"), but I think much of the time users just need a gentle reminder. It's really the low hanging fruit of accessibility in many ways, but alt tags are still commonly missing from Drupal 7 sites. How can we change the initial config so that with Drupal 8 content admins find it easier to include this additional information?
I do like the idea of your module for those folks who need to meet higher accessibility guidelines. Could even fold it into an existing module like: http://drupal.org/project/accessible
Let us know how we can help & what elements you're interested in including in this module.
Comment #19
jenlampton@mgifford
Yes, that's how a "required" field behaves :) Right now we don't even have the *ability* to make this field required without custom code - that needs to change. But I certainly think it should not be enabled by default.
Comment #20
mgiffordI see required fields as stopping the process. So you can't finish with the image unless you've added the alt text. It's the big red warning in the form process that means you can't complete the submission.
I would like to see that even without alt tags being a required field that users are gently reminded by a nice reminder message that the quality of their post would be improved if they added alt text to their images. Nothing that stops workflow, but simply provides a yellow reminder that something was missed. Something easy enough to ignore if it's not deemed important.
Something that could be disabled if no reminder was desired.
But yes, the lack of an ability to do this in core is something we need to fix in D8. We got images in which was no small feat, but....
Comment #21
jenlamptonHm. A warning is an interesting idea. I'm not *sure* that needs to live in core, but if we'd be adding the option to make a field required, we might as well allow 'alerted' (we'll need to come up with a new name for that state!) as well.
Comment #22
xanoComment #23
mgiffordOk, what do we need to see this move forward?
1) Screenshots indicating the best & worse case for alternative text usage with images
2) Feedback from UX folks
3) A patch & agreement around the patch
4) Someone to RTBC it.
Am I missing something?
So can someone summarize the best case senario in a series of pretty screen shots?
Comment #24
quicksketchI'd still like to vote for leaving this out of core. Let contrib handle it (in fact it already has):
http://drupal.org/project/accessible (and #887424: Make alt text required on imagefields)
http://drupal.org/project/eim
If your site is going to require 100% compliance with accessibility standards, you MUST train your end-users. Forcing them to enter alt text isn't going to mean that they're going to actually use the Alt field correctly. If you want to force this upon your end-users, you can use a contrib solution.
Comment #25
Everett Zufelt commented@mgifford
I think the first step is a strong rationale to support the proposed change to Core, that persuades a number of people that this is the right direction to go. I'm personally opposed to making this enabled by default, so it would be best as an Image field setting, defaulted to off.
I also don't rank this very high in my D8 accessibility priority list, so although I will support anyone working on the issue, I will not be working on it myself.
Comment #26
mgiffordAlt tags are the low hanging fruit of web accessibility. We have done lots of work on improving accessibility of Drupal 7, but because the extra work that's required to incorporate alt tags in Core's image handling it generally isn't done by default. If the best we can agree on is ship core so that you can enable required alt text by default, fine. However, alt text should be listed as an option by default and there should be no additional work
If the "Enable alt field" is checked by default that's a good start http://drupal.org/files/issues/Editing_Image_Field.png
Making a similar option to have it be a required field would be a good addition.
Comment #27
quicksketchThe Alt field is enabled on new installs of D7 and D8 for the "field_image" field that is added by the default install profile (the title field is not enabled on it).
The Alt field is not enabled by default when adding new image fields.
Comment #28
mgiffordThanks for the clarification. Been too long since I set up a default vanilla install.
Comment #29
mgiffordI'm going to mark this postponed until we get a stronger argument for why it needs to be in core.
Comment #30
danny englanderI am the original person who opened this issue, little did I know this would develop into an interesting conversation that has spanned the last 18 months and three versions of Drupal. That being said, as I have been using Drupal for some time now, one thing my site users and editors always ask for is good SEO. That usually comes up in initial rounds of conversation of what the client wants out of their new web site. What I have discovered is that no matter how much training I have provided to my end users, when it comes down to it, they simply will not input info into a field unless it's required some of the time.
Though this issue has been geared more toward good accessibility, I think SEO is worth mentioning too. (i.e. an image with a title and alt tag probably will look better to a search engine, that's kind of web 101). It looks like the EIM module (mentioned here above) provides for required alt and title text and I am going to test that out.
So in a way, there's two good arguments for core, Accessibility and SEO but for now It looks like EIM will do the job.
Comment #31
mgiffordI've re-opened this issue and added some SEO tags. EIM will work for D7, but would be good if this functionality could be brought into D8.
Thanks @highrockmedia
Comment #32
Everett Zufelt commentedI haven't read back through the comments. But, would it be acceptable for the default image field widget to have an toggle to require alt text, that defaults to off? If we can build consensus on this by May 4 I will roll the patch on May 4.
Comment #33
danny englander@Everett Zufelt -- You mention alt text in #32 above but I think it would also be nice to have the Title text as a possible required item as well.
Comment #34
leenwebb commentedWhile contrib modules are a great solution in the meantime, moving the ability to require alt tags into core will enhance the base product and make it easier for the average administrator to build accessible sites.
(via Montreal Accessibility Sprint)
Comment #35
Bojhan commentedLets do #32.
Comment #36
mgiffordWho is going to write up a patch that gives us the functionality specified in #32?
Comment #37
lundj commentedWould also like to see #32 implemented... Maybe also for D7?
Comment #38
eiriksmI have also found myself writing this in a custom module several times, so I would also like to see this in core. Although the contrib module does not have to be advanced to add the functionality, it would be a nice accessibility feature to have in core.
So here is a patch adding the functionality. Obviously extremely simple. I included the option on both the title field and the alt field. I can write up some tests when (and if) we think we are heading the right direction.
Comment #40
eiriksmShould probably put this back to needs review? Can't imagine that those errors had anything to do with this patch.
Comment #41
mgifford#38: drupal-alt-field-required-815144-38.patch queued for re-testing.
Comment #43
mgifford#38: drupal-alt-field-required-815144-38.patch queued for re-testing.
Comment #44
mgifford#38: drupal-alt-field-required-815144-38.patch queued for re-testing.
Comment #45
mgiffordNice to be able to force a standard.
Comment #46
falcon03 commentedIMO this is not a minor feature. so changing status.
I applied the patch and it works nicely, except that when clicking the "upload" button next to an image field it shows the errors to inform that alternate field or title field are required (when they are set to be required). This is a problem, because users cannot enter values for alt or title before clicking the "upload" button!
Also tagging for tests; I hope that we get this in before feature freeze!
Comment #47
mgifford#38: drupal-alt-field-required-815144-38.patch queued for re-testing.
Comment #49
danny englanderI tried applying the patch but got an error:
I have the patch in my root drupal 8 directory and type:
git apply drupal-alt-field-required-815144-38.patchI then grabbed the code from:
http://drupalcode.org/project/drupal.git/blob_plain/efa195acbdc13fb69635...
... and applied the patch and it worked fine.
That being said, now that I have tested it, I am having the same issue as #46 above. The required verification should probably happen on node save as with any other required fields, not at the time of upload. I think this would be a better UX.
Comment #50
danny englanderOne other issue I just ran into with this is if there are eixsting images for a given field that did not have any alt and or title text and then you decide to impose required alt or title, when you go to remove an existing image that did not have the text, you get an error that the fields are required. I think that might be related to:
Delete button triggers form validation - change to Delete link for entities with URI
Comment #51
eiriksmFinally got some time to rewrite and clean up this one. Attached patch addresses the following:
1 Now applies cleanly again.
2 Does not complain about required when uploading.
3 Does not complain about deleting fields when alt/title is empty.
4 Has a test to ensure that fields with required alt/title can not be saved.
I had to do a "workaround" to avoid issues 2 and 3, because #required in form api triggers validation in these kinds of processed fields. So instead I added a element_validate function that does not get run if the triggering element has "file_managed_file_submit" as one of the submit callbacks (this applies to both delete and upload buttons).
Does that sound reasonable? Please review, so we can try to get this in (only days to go!).
Comment #52
danny englanderI just tested the latest patch in #51 and the only issue now seems to be with:
To test this:
That's probably an extreme edge case so I am not sure about the relevancy of it but at any rate the main functionality is working.
Comment #53
eiriksmAh, what a miss. Sorry about that. And it was not an edge case, it applied to all nodes with an empty image field :)
New patch attached. Same functionality, including fixing your edge case.
One case it would seem strange is the following:
- The user has a bunch of nodes and turns on alt field required
- The user tries to edit the title of an old node with no alt on the image.
- The user can not save his changes before he fills in alt field.
Could be confusing for some, but should be expected behaviour IMO.
Comment #54
danny englander@eiriksm - yes that's great, just tested again and it's all good this time. Thanks!
Comment #55
mgiffordGood enough to mark RTBC? If so, please do so.
Comment #56
danny englander@mgifford - who would usually set to RTBC the author of the patch or those who have tested like me? Thanks :)
Comment #57
mgiffordIt's almost always the person who tested it like you @highrockmedia
It's very rare that the person who posted the patch is actually allowed to make the patch RTBC. It happens occasionally, particularly if it's already been marked RTBC a few times by others. Sometimes things go back/forth.
Comment #58
danny englanderOk, then make it so. Thank you to all who helped out with this!
Comment #59
cbNice work on this guys!
Comment #60
webchickAwesome!
Committed and pushed to 8.x. Thanks!
Comment #63
anybodyThanks a lot for your work here.
A simple question: What do you think about a separate permission to allow / disallow to enter values into the ALT / TITLE text fields for roles?
New issue?
Comment #64
mgiffordYup, this would be a new issue. Make sure to link to this one though as a related issue.