I don't want the alternative text to images to be required to add an image with ckeditor.

Is there a possiblity to make it optional ? Or maybe to set a default value ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

usethe23 created an issue. See original summary.

saurabh rawat’s picture

you can apply this patch if you don't want to add alt text to an iamge in ckeditor.

saurabh rawat’s picture

Status: Active » Needs review
saurabh rawat’s picture

Status: Needs review » Fixed

I think you can apply this patch and it will fix your issue.

cilefen’s picture

Actually the right way would be a form alter implementation.

usethe23’s picture

Thank you for your help, it works fine. but i'm not sure if this is the right way to do it like @cilefen said.

saurabh rawat’s picture

#6, you can also use below custom code to override the attributes of editor.

Make a custom module and write below code in .module file .

<?php
function form_overwrite_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'editor_image_dialog' ) {
$form['attributes']['alt']['#required'] = FALSE;
}
}

usethe23’s picture

Thank you saurabh rawat it works ! Thank you for your help !

Wim Leers’s picture

Issue summary: View changes
FileSize
50.89 KB

Eh…

The solution is right there ;) Enter "".

Also, blind users will curse you.

cilefen’s picture

Wim, good point on the helpful error text! I did not know it says that.

Status: Fixed » Closed (fixed)

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

localnetwork’s picture

function yourcustom_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
	if(isset($form) && $form_id == "editor_image_dialog") {
    	$form['attributes']['alt']['#required'] = FALSE; 
    }
}
hehongbo’s picture

What I'm more concerned about is not cursed by blind people, but a group of content editors writes variants of useless stuff in the "Alternative Text" field. We often run into situations when we have to put a lot of content on our website in a short amount of time and get a lot of content editors involved to do this together. Many of them write paired quotes “” instead of "" because we are working in zh-hans and probably their input methods did that, and some of them write random stuff like 1, aaa, 123. It makes me feels bad when looking through our database that I want to shut it down immediately.
I know Drupal is a platform where accessibility is a thing but in many cases people don't want to spend time on a field that is invisible if they're in a rush, and emphasize the importance of accessibility by technically making this field "required" is probably not a good thing.