-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.0] Media fields accessibility - second try #27712
Conversation
Awesome!!! - Works perfectly for me. Two suggestions
|
If the idea is to implement this just in media custom field,
Otherwise |
plugins/fields/media/media.php
Outdated
{ | ||
$fieldNode->setAttribute('type', 'accessiblemedia'); | ||
} | ||
|
||
$fieldNode->setAttribute('hide_default', 'true'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be set on the media field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SharkyKZ Are you sure. If so, I don't understand it correctly. I want to overwrite this line:
$node->setAttribute('type', $field->type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean hide_default
attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. That is not part of this PR. I think we should do it in a separate PR, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is part of this PR. $fieldNode
is now a Subform field but hide_default
property belongs on the media field which is now inside the subform.
Personally I'd just remove AccessiblemediaField
and use Subfields as example. This is basic code for implementing the subform with media and alt fields:
// This is now the subform field.
$fieldNode->setAttribute('type', 'subform');
// Add form to subform.
$form = $fieldNode->appendChild(new DOMElement('form'));
// This is the media field.
$media = $form->appendChild(new DOMElement('field'));
$media->setAttribute('type', 'media');
$media->setAttribute('name', 'filename');
$media->setAttribute('hide_default', 'true');
// Thie is the alt field.
$alt = $form->appendChild(new DOMElement('field'));
$alt->setAttribute('type', 'text');
$alt->setAttribute('name', 'alt');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same is needed for other parameters like directory
. It's currently not working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your are right. I now understand what you mean.
@SharkyKZ The idea is to use a different form field if an alternative value can be entered. Not |
Thank you, done. |
Thanks again. Please see if you think that's good. |
No image is selected, yet it is displayed on the frontend as a broken image. |
…ot be possible to use a media field without alt text. If the user want no separate alt, he can leave the text field empty.
@SharkyKZ I want to make sure I understand you correctly in the comment here: #27712 (comment) In my opinion is the check you would like to have in the plugin not wrong in the field and I have now expanded it. -- If I understand you correctly, you think that this check should be done in the plugin, since it is only necessary in the plugin. It is not necessary in the Field. -- In the case of the plugin it could be, that we have an "old" custom field, that was created using the -- You're right, I created this check in the field in order to make the value of the custom fields backwards compatible. But: A check at this point will correct other possible errors. In my opinion the check is even better at this point. -- Do I see that correctly, or are there other reasons to check the value in the custom field that I don't see? |
The check should be in the plugin because it looks like it is a workaround for the plugin. Library code should not have extension specific hacks. But if the intention is to have this field as a drop-in replacement for |
@SharkyKZ Thanks for the feedback.
I don't see any way to do this in the plugin. But I like to be instructed when others prefer it.
This field should be an alternative to the media field, where you don't have to add a text field for the alternative text in a form. Everything is together - it belongs together. |
@astridx Shall I resolve the conflict in file |
@richard67 I think I managed it myself. But it would be good if you could check. I am not good at conflict resolution. I usually delete the branch and do it from scratch. |
@zero-24 I just saw that you requested a change. But I don't really know what to change. Can it be that this request is no longer current or can you help me? |
@astridx Was an easy conflict and you solved it the right way. I was sure you can do that yourself, just offered my help because I saw if and thought maybe you are too busy with other things. |
@astridx Possibly @zero-24 meant this comment #27712 (comment) about the missing doc block? |
I'm merging this because it's definitely a step in the right direction and we can tweak this moving forwards as required. Thankyou very much @astridx |
@Scrabble96 Could you open a new issue for that it there is not already one found by a quick view? That would be helpful. Thanks in advance. |
I opened the new issue (#29640) as requested, but no-one except me has commented and adding/editing any code for a PR is way beyond me. Thanks. |
This PR continues the awesome work of @astridx in joomla#27712 by correcting the behaviour of the alt text and changing the strings to match the work done in joomla#31318
* [4.0] Accessible media field ALt Text This PR continues the awesome work of @astridx in #27712 by correcting the behaviour of the alt text and changing the strings to match the work done in #31318 * remove comment * Update plugins/fields/media/tmpl/media.php Co-authored-by: Quy <quy@fluxbb.org> Co-authored-by: Quy <quy@fluxbb.org>
Pull Request for Issue #27571 .
Please see #27650 and #27712 (comment) for test instructions.
In this Pull Request I tried to implement a suggestion from this comment - I use the Subform Field.
Edit: 10th of February
Test Instructions - You do NOT need composer or npm
old
.new
.new
is still shown correctly in front end.When you edit an article, the text field for the alternative text is not show for theold
custom field at the begin. But when you delete the image temporarily the text field appear and you can use it.a) Add
somewhere for example in line 276 of
/administrator/components/com_contact/forms/contact.xml
.b) If you use my example add
in
/administrator/components/com_contact/tmpl/contact/edit.php
line 55.c) See that you can use the field.