User tests: Successful: Unsuccessful:
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. old
custom field at the begin. But when you delete the image temporarily the text field appear and you can use it. <field
name="image2"
type="accessiblemedia"
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
directory="banners"
/>
somewhere for example in line 276 of /administrator/components/com_contact/forms/contact.xml
.
b) If you use my example add
`<?php echo $this->form->renderField('image2'); ?>`
in /administrator/components/com_contact/tmpl/contact/edit.php
line 55.
c) See that you can use the field.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration Language & Strings Libraries Front End Plugins |
Title |
|
If the idea is to implement this just in media custom field, Joomla\CMS\Form\Field\AccessiblemediaField
is not required. The form can be added directly in the plugin like here
Otherwise AccessiblemediaField
should not have a dependency on media field plugin.
@SharkyKZ The idea is to use a different form field if an alternative value can be entered. Not media
, but accessiblemedia
. And accessiblemedia
inherits from subform
.
This is not a nice object-oriented. I know. accessiblemedia
should be a child of the media field semantically correct.
Labels |
Added:
?
?
|
@brianteeman In the generated code when the field is presented you have a small bug as the generated code is
Thank you, done.
@brianteeman Sorry there is another small issue when using the field in the front end
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.
Category | Administration Language & Strings Libraries Front End Plugins | ⇒ | Administration com_content Language & Strings Layout Libraries Front End Plugins |
Category | Administration Language & Strings Libraries Front End Plugins com_content Layout | ⇒ | Administration Language & Strings Layout Libraries Front End Plugins |
Today I changed this PR.
I have introduced a new field named accessiblemedia
.
In my opinion, an alt text
belongs to a field that inserts an image.
And this is a way of making a field type available for this purpose without breaking backward compatibility. The media
field remains. I actually wanted to expand the media
field. That would be more semantically correct. But then I did expand the Subfield
field. I found this easier.
I do not change anything in the custom field anymore. The accessiblemedia
field is now automatically loaded here. And an alt text is inserted in any case. At least an empty one.
What is important to me: Now, the field can also be used in other places.
So, new test instructions:
Create a Custom Field of type media and see, that you have to insert an alt text and that this text is displayed in the front end. (more detailed explanation here)
Use the new form field
a) Add
<field
name="image2"
type="accessiblemedia"
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
hide_none="1"
/>
somewhere for example in line 276 of /administrator/components/com_contact/forms/contact.xml
.
b) If you use my example add
`<?php echo $this->form->renderField('image2'); ?>`
in /administrator/components/com_contact/tmpl/contact/edit.php
line 55.
c) See that you can use the field.
For my example up to know you can not display it in the front end, because it is not saved in the database. And for this, the array value has to cast into a string. But it works.
If you like my idea I will create a more detailed test instruction.
I thank you for the patience with me so far and look forward to further tips for improvements.
@SharkyKZ I looked at what you think should be implemented, the addition of the text field for the alt text in the media custom field method onCustomFieldsPrepareDom. But: I liked this version better. Do you think so too? You know your way around better with Joomla, so I would reconsider if you disagreed.
@brianteeman It's not nice if you submit a PR and nobody cares. I am always happy that you test and you will always find something with me :)
@Quy I added all your suggestions. Thank you.
I will take another look tomorrow
Most code in layouts/joomla/form/field/media/accessiblemedia.php
(except rendering part) should be in field class.
Not sure if it is something I am doing wrong but after creating the field and then trying to use it to add an image to an article the article is saved BUT the image is not
I have tested this item
@brianteeman Thanks for your test. You are super fast.
Now I hope that my version is technically OK.
Looks better now but there are still some issues. Existing field values are not being handled.
@SharkyKZ Thanks for your tips.
I have corrected backwards compatibility and extended the test instructions.
<field
name="image2"
type="accessiblemedia"
label="COM_CONTACT_FIELD_PARAMS_IMAGE_LABEL"
directory="banners"
/>
somewhere for example in line 276 of /administrator/components/com_contact/forms/contact.xml
.
b) If you use my example add
`<?php echo $this->form->renderField('image2'); ?>`
in /administrator/components/com_contact/tmpl/contact/edit.php
line 55.
c) See that you can use the field.
Maybe someone can convince the accessibility team to test this
Labels |
Added:
?
|
Labels |
Added:
?
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
@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 MediaField
(not the AccessiblemediaField
- That will be the case, if Joomla Version 3 is updated to Version 4). In this case, the value
does not contain an alt text. It is a simple string, for example: "images/joomla_black.png"
.
For showing everything (image and alt text) correctly in back end the AccessiblemediaField
need da json string like this: "{"imagefile":"images\/banners\/banner.jpg","alt_text":""}"
because it is a child of the SubformField
.
(I did not extend the MediaField
, because I could reuse more. And as a SubformField
we always have the possibility to add other things that belong to the field in the same way.)
--
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 Joomla\CMS\Form\Field\MediaField
in other places, maybe it's fine.
@SharkyKZ Thanks for the feedback.
The check should be in the plugin because it looks like it is a workaround for the plugin.
I don't see any way to do this in the plugin. But I like to be instructed when others prefer it.
In my opinion, it is even better as it is in this PR, because other possible errors are also caught here.
But if the intention is to have this field as a drop-in replacement for
Joomla\CMS\Form\Field\MediaField
in other places, maybe it's fine.
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.
In my opinion it is not possible to replace the previous field with backward compatibility.
Labels |
Added:
?
Removed: ? |
@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.
@astridx Possibly @zero-24 meant this comment #27712 (comment) about the missing doc block?
Labels |
Added:
?
Removed: ? |
Labels |
Added:
?
Removed: ? |
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-05-30 11:28:05 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
Removed: ? |
@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.
Awesome!!! - Works perfectly for me.
Two suggestions