Problem/Motivation

Users have no indication if the "alt text required" option has been enabled on the image field because the usual Red Asterisk indicating a field is required is not being shown next to this field.

Proposed resolution

Add the "required" attribute to this field.

Before

After

a screengrab showing asterisk on the alt field

Remaining tasks

  • Write patch #88 by @claudiu.cristea
  • Code review
  • Manual test by @kattekrab

User interface changes

Yes. An improvement! But a very small change.

API changes

None?

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because this is a usability problem and easily fixed.
Issue priority Normal - it's not actually preventing anything from working, but will be a win for overall accessibility and WCAG compliance.
Unfrozen changes Unfrozen because it simply adds an indicator that the alt tag is a required field, which is missing currently.
Prioritized changes The main goal of this issue is usability & accessibility
Disruption Minimal to none

Original report by @mgifford

Required * isn't present on required alt text. Probably same on the Title too.

<div class="form-item form-type-textfield form-item-field-image2-fr-0-alt">
<label for="edit-field-image2-fr-0-alt">Alternate text</label>
<input id="edit-field-image2-fr-0-alt" class="form-text" type="text" maxlength="512" size="60" value="What with alt text" name="field_image2[fr][0][alt]" aria-describedby="edit-field-image2-fr-0-alt--description">
<div id="edit-field-image2-fr-0-alt--description" class="description">This text will be used by screen readers, search engines, or when the image cannot be loaded.</div>
</div>

It is required and you get the error message but no red "*"

CommentFileSizeAuthor
#93 1906264-asterisk.png35.55 KBkattekrab
#89 Screen Shot 2015-02-01 at 1.28.59 pm.png228.83 KBkattekrab
#89 Screen Shot 2015-02-01 at 1.23.13 pm.png43.06 KBkattekrab
#88 interdiff-to-84.txt2.29 KBclaudiu.cristea
#88 required_alt_tag-1906264-88.patch4.33 KBclaudiu.cristea
#86 1987832-system_test-controller-9.patch7.45 KBSivaji_Ganesh_Jojodae
#84 required_alt_tag-1906264-84.patch4.32 KBamitgoyal
#79 required_alt_tag-1906264-79.patch4.35 KBmgifford
#76 interdiff.txt769 bytesclaudiu.cristea
#76 required_alt_tag-1906264-76.patch4.32 KBclaudiu.cristea
#71 drupal-alt_title_required-1906264-71.patch4.31 KBmitsuroseba
#68 drupal-alt_title_required-1906264-68.patch4.33 KBmitsuroseba
#66 drupal-alt_title_required-1906264-66.patch4.32 KBmgifford
#63 interdiff-1906264-56-63.txt482 bytesamitgoyal
#63 drupal-alt_title_required-1906264-63.patch4.83 KBamitgoyal
#58 Screen Shot 2014-08-10 at 10.35.37 AM.png89.34 KBmgifford
#56 interdiff-1906264-54-56.txt867 bytesmitsuroseba
#56 drupal-alt_title_required-1906264-56.patch4.83 KBmitsuroseba
#54 drupal-alt_title_required-1906264-54.patch4.82 KBmitsuroseba
#52 interdiff-1906264-50-52.txt1.1 KBmitsuroseba
#52 drupal-alt_title_required-1906264-52.patch5.04 KBmitsuroseba
#50 drupal-alt_title_required-1906264-50.patch5.26 KBmitsuroseba
#48 drupal-unit_test_for_required_tag_alt_text-1906264-48.patch5.45 KBmgifford
#43 drupal-unit_test_for_required_tag_alt_text-1906264-43.patch1.79 KBjohanv
#42 drupal-unit_test_for_required_tag_alt_text-1906264-42.patch1.79 KBjohanv
#42 Screenshot from 2013-10-09 14:51:10.png37.26 KBjohanv
#42 Screenshot from 2013-10-09 14:51:42.png82.4 KBjohanv
#40 drupal-alt_title_required-1906264-40.patch5.24 KBmgifford
#38 drupal-unit_test_for_required_tag_alt_text-1906264-38-do-not-test.patch1.79 KBjohanv
#35 drupal-alt_title_required-1906264-35.patch3.45 KBmgifford
#32 drupal-alt_title_required-1906264-32.patch4.06 KBmgifford
#24 drupal-alt_title_required-1906264-23.patch4.03 KBmgifford
#19 interdiff-1906264-5-17.txt3.08 KBmgifford
#17 drupal-alt_title_required-1906264-17.patch4 KBmgifford
#14 Screen Shot 2013-03-07 at 10.25.22 AM.png52.07 KBmgifford
#11 drupal-alt_title_required-1906264-5.patch4.27 KBblueminds
#9 drupal-alt_title_required-1906264-4.patch4.12 KBblueminds
#6 drupal-alt_title_required-1906264-3.patch3.52 KBblueminds
#3 AltTextRequired.png180.12 KBmgifford
#2 drupal-alt_title_required-1906264-2.patch2.69 KBblueminds
#1 drupal-alt_title_required-1906264-1.patch4.9 KBblueminds
ImageAltRequired-NoAst.png81.24 KBmgifford
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blueminds’s picture

Category: bug » feature
Status: Active » Needs work
FileSize
4.9 KB

I am afraid this cannot be fixed easily. Moreover I think this is by the design and not really a bug.

The problem is that on hitting the upload button it gets validated. So there is a custom validation callback for the alt and title attributes that take into account if the file has been initially uploaded or the form is actually being submitted as a whole. In case you set the field to be #required you will get error messages just after hitting the Upload button, which is not correct as from the user point of view the error has not occurred. You can mess around with #limit_validation_errors for upload and remove buttons, but it will not work properly for remove action in case you remove item that is not the last one. Attaching patch with which I could come up... maybe someone else will be able to handle it.

Another solution would be to simply display Alt/Title fields implicitly for new items.

blueminds’s picture

sorry, includes some phpunit stuff, so fixed patch

mgifford’s picture

Status: Needs work » Needs review
FileSize
180.12 KB

Well, I haven't looked at the code in any depth, but the output is working.

blueminds’s picture

Status: Needs review » Needs work

try following:

- add multiple images
- hit any Remove action but the last one

result will be that all the items that followed get removed as well.

So if this can be fixed then we are fine. But I could not come up with reasonable solution, it looks like the problem is that $form_state gets rebuild in a different way then the submit_validation_errors arrays are built and so the remaining items get removed from $form_state['values'].

mgifford’s picture

Well, I can confirm that this is a problem that is introduced in the patch.

I'd say it isn't something that is acceptable as it is introducing a bug.

blueminds’s picture

So another step in evolution :)

This patch work just fine. However, introduces one small bug - when I upload an image, fill out alt or title, then upload another one without saving the whole form the values I previously entered for title and alt are gone. So if this gets solved, I think we have what we wanted.

mgifford’s picture

Sorry, does the patch in #6 address this? Not sure why you didn't engage the bot. Just not sure how to move this issue ahead.

kim.pepper’s picture

Status: Needs work » Needs review

Engaging the bot...

blueminds’s picture

With this patch it should all work nicely. Please try out.

Status: Needs review » Needs work

The last submitted patch, drupal-alt_title_required-1906264-4.patch, failed testing.

blueminds’s picture

Status: Needs work » Needs review
FileSize
4.27 KB

another try

Status: Needs review » Needs work
Issue tags: -Accessibility

The last submitted patch, drupal-alt_title_required-1906264-5.patch, failed testing.

blueminds’s picture

Status: Needs work » Needs review
Issue tags: +Accessibility
mgifford’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
52.07 KB

Patch seems to work well. I did a quick review of the code and it made sense to me. Good to extend function image_field_widget_process().

Required text * visible

xjm’s picture

xjm’s picture

Category: feature » bug
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks @mgifford and @blueminds!

This looks like an accessibility bug to me. Also, I think we probably need to add an automated test for this?

Also, a few minor suggestions for the comments:

  1. +++ b/core/modules/image/image.field.incundefined
    @@ -358,9 +362,45 @@ function image_field_widget_process($element, &$form_state, $form) {
    +  // The following code dealing with limit validation errors is the logic that
    +  // avoids triggering error messages on elements that are accompanying the
    +  // field element. These are alt and title elements. The idea is to dynamically
    +  // build the definition of which fields should not be validated.
    

    This comment could be simplified and clarified a lot. For example, the whole first line is superfluous.

  2. +++ b/core/modules/image/image.field.incundefined
    @@ -358,9 +362,45 @@ function image_field_widget_process($element, &$form_state, $form) {
    +    // In case the triggering element is not set - form is being rendered - or in
    +    // case the rendering element is "Upload" - user uploaded new file - build
    +    // the limit validation error array.
    

    This could also be shortened and clarified. Also, the first line is over 80 characters.

  3. +++ b/core/modules/image/image.field.incundefined
    @@ -358,9 +362,45 @@ function image_field_widget_process($element, &$form_state, $form) {
    +      // For files that have just been uploaded validate only the fid.
    

    There should be a comment after "uploaded," and let's say "file ID" instead of "fid."

  4. +++ b/core/modules/image/image.field.incundefined
    @@ -358,9 +362,45 @@ function image_field_widget_process($element, &$form_state, $form) {
    +        // Here we need to set the alt and title values from POST as the limit
    +        // validation logic will remove them from form_state.
    

    The words "Here we need to" can be removed.

  5. +++ b/core/modules/image/image.field.incundefined
    @@ -358,9 +362,45 @@ function image_field_widget_process($element, &$form_state, $form) {
    +      // Previously uploaded files - validate whole field.
    

    I'd change this to "Validate the whole field for previously uploaded files."

  6. +++ b/core/modules/image/image.field.incundefined
    @@ -358,9 +362,45 @@ function image_field_widget_process($element, &$form_state, $form) {
    +    // Set the built limit validation error definition array for upload as well as
    +    // for the remove button.
    

    This can also be simplified. I'd suggest "Limit validation errors for the upload and remove buttons."

mgifford’s picture

Status: Needs work » Needs review
FileSize
4 KB

In number 3 above, what did you mean by "There should be a comment after "uploaded,"?

I applied the rest, trying to simplify the comments as you suggested.

So, we still need automated testing needed.

xjm’s picture

@mgifford Can you provide an interdiff? Thanks!

mgifford’s picture

FileSize
3.08 KB

I hate interdiff's. Understand why they are useful, but I've found that none of the explanations I've seen:
http://drupal.org/documentation/git/interdiff
http://hojtsy.hu/blog/2012-apr-13/quick-and-simple-interdiffs
http://xjm.drupalgardens.com/blog/interdiffs-how-make-them-and-why-they-...

really help. They work fine if you're already doing this as part of your workflow, but otherwise.

There was also stuff missing like, how do you delete a branch:
git branch -D old_patch

or steps like adding the code to the repo.

It's also particularly frustrating to try to follow these instructions already having 2 patches built, but not being able to apply the second on because the assumption is that you haven't already built the second patch...

Anyways, hope that this approach work. It's still awkward, but might well be better.

I just went to a Linux box though and installed interdiff sudo apt-get install interdiff and then am doing it with:
interdiff old.patch new.patch > interdiff.txt

Hope this interdiff helps.

xjm’s picture

Not really the place to talk about all this on issue, but ask in IRC if you're having any difficulty with git and folks will help.

There was also stuff missing like, how do you delete a branch:
git branch -D old_patch

I'm not sure how that can be "missing" from a doc that has a very specific purpose. That's elsewhere in the git documentation.

It's also particularly frustrating to try to follow these instructions already having 2 patches built, but not being able to apply the second on because the assumption is that you haven't already built the second patch...

Create two branches. Apply your old patch to the first and your new patch to the second. Diff the second branch against the first. There's your interdiff. You can diff anything against anything in git; the instructions are just for a common usecase.

I just went to a Linux box though and installed interdiff sudo apt-get install interdiff and then am doing it with:
interdiff old.patch new.patch > interdiff.txt

IIRC that's also suggested in a lot of the documentation.

mgifford’s picture

Thanks @xjm.. I'll get it eventually... Hope the interdiff I provided helps.

mgifford’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Accessibility

The last submitted patch, drupal-alt_title_required-1906264-17.patch, failed testing.

mgifford’s picture

Status: Needs work » Needs review
FileSize
4.03 KB

Just a re-roll of #17.

mgifford’s picture

mparker17’s picture

shanly’s picture

Assigned: Unassigned » shanly

I'm reviewing and testing.

shanly’s picture

Assigned: shanly » Unassigned
Status: Needs review » Needs work
+++ b/core/modules/image/image.field.inc
@@ -360,9 +364,41 @@ function image_field_widget_process($element, &$form_state, $form) {
+          $item['alt'] = $_POST[$instance['field_name']][$element['#language']][$element['#delta']]['alt'];

Is this a potential XSS vulnerability? Should it be sanitized here or is it already sanitized or sanitized after?

+++ b/core/modules/image/image.field.inc
@@ -360,9 +364,41 @@ function image_field_widget_process($element, &$form_state, $form) {
+          $item['title'] = $_POST[$instance['field_name']][$element['#language']][$element['#delta']]['title'];

Is this a potential XSS vulnerability? Should it be sanitized here or is it already sanitized or sanitized after?

mgifford’s picture

Status: Needs work » Needs review
mgifford’s picture

I'm pretty sure they'd need to be sanitized because it is being pulled right from the $_POST.

Status: Needs review » Needs work

The last submitted patch, drupal-alt_title_required-1906264-23.patch, failed testing.

mgifford’s picture

Status: Needs work » Needs review
FileSize
4.06 KB

re-roll with added check_plain().

mgifford’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Accessibility

The last submitted patch, drupal-alt_title_required-1906264-32.patch, failed testing.

mgifford’s picture

Status: Needs work » Needs review
FileSize
3.45 KB

Reroll. 3 of 4 chunks failed.

Status: Needs review » Needs work

The last submitted patch, drupal-alt_title_required-1906264-35.patch, failed testing.

mgifford’s picture

johanv’s picture

Status: Needs work » Needs review
FileSize
1.79 KB

I did not fix the issue, but here is a unit test, which obviously fails, because the bug is still unfixed. That's why I added -do-not-test to the patch name.

claudiu.cristea’s picture

Status: Needs review » Needs work

Let's see how fails. Can you repost without suffix, so that we can see the test running and failures?

mgifford’s picture

Status: Needs work » Needs review
FileSize
5.24 KB

This is a combination of #35 & #38, both of which still apply with no problems. Let's see what errors this causes.

Status: Needs review » Needs work

The last submitted patch, drupal-alt_title_required-1906264-40.patch, failed testing.

johanv’s picture

As requested in #39, the unit test without do-not-test. Which will fail.

I tried the patch from #40 as well with simpletest.me. I configured the story content type to make the alt text of the image required. When I then want to add a new story, I get notices 'Undefined variable: settings in image_field_widget_process()'. (see attached screenshot)

And when I select an image, the required indicator for the alt text is not shown. (see other attached screenshot)

johanv’s picture

Status: Needs work » Needs review
FileSize
1.79 KB

Oops, I forgot to change the status to 'Needs review'. Sorry.

claudiu.cristea’s picture

OK. Cancelled the test from #43.

The last submitted patch, drupal-unit_test_for_required_tag_alt_text-1906264-43.patch, failed testing.

Anonymous’s picture

Issue summary: View changes

Adding screenshot to display

mgifford’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 43: drupal-unit_test_for_required_tag_alt_text-1906264-43.patch, failed testing.

mgifford’s picture

The module moved to core/modules/image/lib/Drupal/image/Plugin/Field/FieldWidget/ImageWidget.php

#43 just includes the test. I've brought it over, but $settings['alt_field_required'] || $settings['title_field_required'] aren't available in $settings any more.

I'm not sure how to properly use getSettings() without $this....

mgifford’s picture

Issue tags: +Needs reroll
mitsuroseba’s picture

Status: Needs work » Needs review
FileSize
5.26 KB

I wrote new patch instead of reroll, because i think it more simple.

Status: Needs review » Needs work

The last submitted patch, 50: drupal-alt_title_required-1906264-50.patch, failed testing.

mitsuroseba’s picture

Status: Needs work » Needs review
FileSize
5.04 KB
1.1 KB

Reroll

barraponto’s picture

+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -216,6 +217,7 @@ public static function process($element, FormStateInterface $form_state, $form)
@@ -239,13 +241,12 @@ public static function validateRequiredFields($element, FormStateInterface $form

@@ -239,13 +241,12 @@ public static function validateRequiredFields($element, FormStateInterface $form
       // We check for the array key, so that it can be NULL (like if the user
       // submits the form without using the "upload" button).
       if (!array_key_exists($field, $image_field)) {
+        $form_state['limit_validation_errors'] = array();
         return;
       }
-      // Check if field is left empty.
-      elseif (empty($image_field[$field])) {
-        \Drupal::formBuilder()->setError($element, $form_state, t('The field !title is required', array('!title' => $element['#title'])));
-        return;
-      }
+    }
+    else {
+      $form_state['limit_validation_errors'] = array();
     }
   }

It seems to me that only the return statement should be within the if clause.

mitsuroseba’s picture

Thanks, @barraponto.
In new path removed $form_state['limit_validation_errors'] = array();

Status: Needs review » Needs work

The last submitted patch, 54: drupal-alt_title_required-1906264-54.patch, failed testing.

mitsuroseba’s picture

Status: Needs work » Needs review
FileSize
4.83 KB
867 bytes

Reroll. Changed randomName -> randomMachineName.

mgifford’s picture

I still don't understand why the code below // Check if field is left empty. is removed..

However the patch works great. I tested it with both Alt & Title text to verify it works well for both as required fields.

I'm basically ready to mark it RTBC based on my tests on SimplyTest.me and review of the code... But I want to know why that code was removed and check that there aren't going to be other implications of this.

mgifford’s picture

Oh ya, a quick screenshot from my tests...

mitsuroseba’s picture

Removed because we have now required attribute on alt and title and not need custom validation.

Without patch message
$form_state->setError($element, t('The field !title is required', array('!title' => $element['#title'])));
uppear when #title_field_required = 1 and submit form not image process.

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

Excellent.. In that case, RTBC.

The last submitted patch, 48: drupal-unit_test_for_required_tag_alt_text-1906264-48.patch, failed testing.

claudiu.cristea’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -241,11 +243,8 @@ public static function validateRequiredFields($element, FormStateInterface $form
+    } else {

Only a small coding standards fix, please. Should be

}
else {
amitgoyal’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
4.83 KB
482 bytes

Please review revised patch with a fix mentioned in #62.

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

Good catch @claudiu.cristea - setting it back.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php
@@ -59,13 +59,50 @@ function testRequiredAttributes() {
+    $this->assertText(t('Alternate text field is required.'), 'Node save failed when alt text required was set and alt text was left empty.');
+    $this->assertText(t('Title field is required.'), 'Node save failed when title text required was set and title text was left empty.');
...
+    $this->assertNoText(t('Alternate text field is required.'), 'Node save not failed when alt text not required was set and alt text was left empty.');
+    $this->assertNoText(t('Title field is required.'), 'Node save not failed when title text not required was set and title text was left empty.');
...
+    $this->assertNoText(t('Alternate text field is required.'), 'Node save not failed when alt text not required was set and alt text was left empty.');
+    $this->assertNoText(t('Title field is required.'), 'Node save not failed when title text not required was set and title text was left empty.');

It would be better if there were no messages here since since the assert's default message will indicate exactly what is the problem.

What I mean is this:

+++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php
@@ -59,13 +59,50 @@ function testRequiredAttributes() {
+    $this->assertText(t('Alternate text field is required.'));
+    $this->assertText(t('Title field is required.'));
...
+    $this->assertNoText(t('Alternate text field is required.'));
+    $this->assertNoText(t('Title field is required.'));
...
+    $this->assertNoText(t('Alternate text field is required.'));
+    $this->assertNoText(t('Title field is required.'));
mgifford’s picture

Status: Needs work » Needs review
FileSize
4.32 KB

@alexpott - That looks pretty easy to implement.

claudiu.cristea’s picture

+++ b/core/modules/image/src/Tests/ImageFieldValidateTest.php
@@ -59,13 +59,50 @@ function testRequiredAttributes() {
+    // look for form-required for the alt text

Nitpick. Capitalize first letter, end with a dot.

mitsuroseba’s picture

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

RTBC if turns green.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 68: drupal-alt_title_required-1906264-68.patch, failed testing.

mitsuroseba’s picture

Status: Needs work » Needs review
FileSize
4.31 KB

Whoa, reroll.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

rtbc

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 71: drupal-alt_title_required-1906264-71.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 71: drupal-alt_title_required-1906264-71.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review
FileSize
4.32 KB
769 bytes

interdiff against #66.

mgifford’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Looks good! Applying it here http://sc61e125c2b67564.s2.simplytest.me/node/add/article

No problem with mandatory values (on alt or title).

Will be great to get this fixed. Thanks again @alexpott for the direction.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -206,6 +206,7 @@ public static function process($element, FormStateInterface $form_state, $form)
+      '#required' => $element['#alt_field_required'],
       '#element_validate' => $element['#alt_field_required'] == 1 ? array(array(get_called_class(), 'validateRequiredFields')) : array(),

@@ -216,6 +217,7 @@ public static function process($element, FormStateInterface $form_state, $form)
+      '#required' => $element['#title_field_required'],
       '#element_validate' => $element['#title_field_required'] == 1 ? array(array(get_called_class(), 'validateRequiredFields')) : array(),

I think we can remove the #element_validate now and remove ImageWidget::validateRequiredFields()

mgifford’s picture

Status: Needs work » Needs review
FileSize
4.35 KB

I had to re-roll the code. However, @alexpott, I don't understand the change you're requesting. Is it just this:

+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -206,6 +206,7 @@ public static function process($element, FormStateInterface $form_state, $form)
+      '#required' => $element['#alt_field_required'],
       '#element_validate' => $element['#alt_field_required'] == 1 ? array(array(get_called_class())) : array(),
@@ -216,6 +217,7 @@ public static function process($element, FormStateInterface $form_state, $form)
+      '#required' => $element['#title_field_required'],
       '#element_validate' => $element['#title_field_required'] == 1 ? array(array(get_called_class())) : array(),

Status: Needs review » Needs work

The last submitted patch, 79: required_alt_tag-1906264-79.patch, failed testing.

mgifford’s picture

Issue tags: +dcamsa11y
kattekrab’s picture

Now that #2303765: Make the default 'alt' attribute for Image fields required is green - we really need to get this one resolved.

kattekrab’s picture

Issue tags: +Needs reroll

Looks like there's something wrong with the patch - there's a bunch of stuff added at the bottom, that looks like it shouldn't be there.

amitgoyal’s picture

Status: Needs work » Needs review
FileSize
4.32 KB

Re-roll of #79.

Status: Needs review » Needs work

The last submitted patch, 84: required_alt_tag-1906264-84.patch, failed testing.

Sivaji_Ganesh_Jojodae’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
7.45 KB

Rerolled patch #84 to prevent git line offset warning.

Status: Needs review » Needs work

The last submitted patch, 86: 1987832-system_test-controller-9.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -dcamsa11y +SprintWeekend2015
FileSize
4.33 KB
2.29 KB

@alexpott, unfortunately #element_validate (and ::validateRequiredFields()) cannot be removed. In fact there we are doing the "required" validation. Why? Because when the form is displayed for the first time the 2 textfields are not displayed and are empty. When an image is picked up the form is submitted and validated and that is causing a validation error. ::validateRequiredFields() is the workaround. See also ::validateRequiredFields() docblock. We are using #required only to get the red * on the form.

Interdiff against #84

kattekrab’s picture

Status: Needs review » Needs work
FileSize
43.06 KB
228.83 KB

Setting back to needs work.

Just did manual test with simplytest.me

Uploaded an image. No indication that alt text is required, also let me save without alt text. So, I'm not getting the error, but the point here was to improve our base accessibility by requiring alt text, and informing editors that they should insert an empty tag if the image is purely decorative.

It has inserted an empty alt tag though.

kattekrab’s picture

Status: Needs work » Needs review

Hmmm.

Been thinking about this. Maybe this is actually better? Quietly just insert the empty alt tag. If most images are purely decorative... maybe this is the way to go? It's less jarring to the user than getting an error. Setting back to needs review for someone else's opinion.

The use of alt text around images isn't always straightforward. And because a field image is often used in multiple contexts (on it's node, but also in lists generated by views, possibly as links from a list view to a node...) it can get quite tricky, and the way forward seems subjective.

Charles Belov’s picture

The content editor needs to make a concious determination whether an image is purely decorative. So defaulting to adding an empty alt attribute is contrary to providing accessibility.

claudiu.cristea’s picture

@kattekrab, @Charles Belov,

Yes, I get the point but in this ticket we are only showing the "required" asterisk to alt & title form elements if the site administrator decided that those fields are required. Setting the alt tag required by default is out of scope. Please fill a follow-up explaining why we need that. I would be happy to provide a patch.

In the meantime if you feel that the patch from #88 has fixed the original requirement, please RTBC.

kattekrab’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
35.55 KB

Oops - of course @claudiu.cristea - Sorry about that!

I tested again, edited the article content type to make the image field required this time, and voila - the asterisk is there now!

You are absolutely right that making it required by default is out of scope. And there is already another ticket for that. See #2303765: Make the default 'alt' attribute for Image fields required which is still at "need work".

Screenshot attached showing "Alternative Text" field now has red asterisk indicating it is a required field. RTBC from manual test. Could probably do with a quick actual code review from someone who reads code.

Thanks @claudiu.cristea!! This is great. I'm updating the issue summary too.

kattekrab’s picture

Issue summary: View changes
kattekrab’s picture

Issue summary: View changes
mgifford’s picture

This looks good to me. Thanks for marking it RTBC @kattekrab - +1

webchick’s picture

Assigned: Unassigned » alexpott

Looks like Alex has been following this one.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed cd57d59 and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed cd57d59 on 8.0.x
    Issue #1906264 by mgifford, mitsuroseba, blueminds, johanv, claudiu....

Status: Fixed » Closed (fixed)

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