#60158 closed defect (bug) (fixed)
The description field for media doesn't automatically make paragraphs in the generated code
Reported by: | juliemoynat | Owned by: | joedolson |
---|---|---|---|
Milestone: | 6.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch commit |
Focuses: | accessibility | Cc: |
Description
There are two ways to edit a media:
- via a modal window where all the contribution fields are only simple textareas;
- via a dedicated web page where "alternative text" and "caption" fields are simple textareas and the "description" field is a WYSIWYG editor in text mode where TinyMCE is deactivated.
For some media, you can need to add a long description just like a transcript (for videos, audios, complex images like infographic, etc.).
So, in these cases, the description field can be used because it's totally appropriate.
But, there is a problem: usually, in editor fields, the paragraphs (<p> elements) are automatically added when you display the web page (in the front view). In this field, they are not.
For accessibility reason, paragraphs need to be HTML paragraphs (WCAG Success Criterion 1.3.1: Info and Relationships (level A)).
I've tried to modify the code in the core to add TinyMCE that is explicitly deactivated and this is fixing the problem.
It's in wp-admin/includes/media.php, on line 3261 where you can just change "false" to "true" for "tinymce":
<?php $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); $editor_args = array( 'textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings, );
So, is it possible to activate TinyMCE for this field? Why is it deactivated?
Or, if it's not possible, is it possible to make this option hookable?
Thank you
Attachments (1)
Change History (16)
This ticket was mentioned in PR #5822 on WordPress/wordpress-develop by @sebastienserre.
11 months ago
#1
- Keywords has-patch added
@mukesh27 commented on PR #5822:
11 months ago
#2
Thanks @sebastienserre for the PR. Left one minor suggestion. Is it possible to add unit test for new filter?
#4
@
11 months ago
- Keywords needs-unit-tests needs-testing added
I unfortunately don't know writing test for the moment :(
This ticket was mentioned in Slack in #core-test by webtechpooja. View the logs.
11 months ago
#6
@
10 months ago
Hi,
Is there any chance that someone who knows how to write unit tests will take over the rest of this small ticket?
Thanks!
This ticket was mentioned in Slack in #accessibility by joedolson. View the logs.
9 months ago
#9
@
9 months ago
- Milestone changed from Awaiting Review to 6.6
This looks good. Since it's just adding a filter, and not actually changing the default behavior, it's pretty safe. I do think that it's not an option to just change the default, since it's very hard to know how the image description has been used on the front-end by existing tools.
Milestoning for 6.6.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
6 months ago
#12
@
6 months ago
- Keywords commit added; changes-requested needs-unit-tests needs-testing needs-testing-info removed
I think that this patch is OK; I'm not convinced it needs unit tests, or what those unit tests would actually be testing. There should be no change in what HTML the field accepts or outputs, just a change in the editor output.
I've modified the patch slightly to clarify the comment, update the version, and clearly state that this only enables TinyMCE in the attachment editing screen; the media modal would be a much bigger change, and probably not worth the effort.
I also want to observe that there are other solutions to getting automatic paragraphs in the description field, such as running wpautop
on the output of the field when it's rendered; and the description field accepts HTML, so they can also be written directly into the text field.
https://core.trac.wordpress.org/ticket/60158