Skip to content

Add file types for media custom field plugin. #45013

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

Open
wants to merge 73 commits into
base: 6.0-dev
Choose a base branch
from

Conversation

sergeytolkachyov
Copy link
Contributor

@sergeytolkachyov sergeytolkachyov commented Feb 25, 2025

When creating a custom field, do you want to be able to select not only images, but also documents, videos, and audio? This PR adds the ability to specify one or more file types for a custom media type field.

Summary of Changes

  • The file types parameter was added to the field parameters during creation.
  • There are 4 file types: images, audios, videos, documents. This list decides which of the allowed file extensions from Media Manager configuration are used.
  • images file type is selected by default and for empty parameter value
  • You can select one or several file types: only videos and documents for example
  • new attribute for Accessiblemedia Form Field: types. Similar to Media field.

Testing Instructions

  • Apply this PR
  • Create a new custom field for articles or contacts.
  • Look at new field parameter - File types
    image
  • save your field with default settings (images type is selected)
    image
  • go to article edit view and try to choose a media file in this field - You'll be able to select only images. This is default Joomla behavior before apply this PR.
    image
    See also a modal window title is Change image
    image
    See also that the image has been rendered successfully in the frontend
    image
  • return to field settings and change file types. For example, unselect an images and select a documents or videos or both of them. Save field params,
    image
  • go to article edit view again and try to select media file in this field. Make sure you can select only documents or only videos as you configured your field. See also a modal window title is Change file
    image
    See that there is no alt text and empty alt fields, but new field link text is present
    image
  • Check that link to download selected file has been rendered successfully in the frontend for documents file types. The link text is download by default. You can specify your own text.
    image
  • Check that <video> tag for selected file has been rendered successfully in the frontend for video file types.
    image
  • Check that <audio> tag for selected file has been rendered successfully in the frontend for audio file types.
    image
  • Go to field settings and change file types and add to file types images. So you have both images and non-images file types selected. Save field params.
    image
  • Go to article edit view and check that alt text and empty alt fields are present with the link text field. So if you'll select an image file - you can use additional field for image. If you'll select a non-image file - you can use a link text field
    image
  • Check modal window title is Change file. Check that you can choose both images and non-images file types.
    image
    image
  • Select document file and check that link to download selected file has been rendered successfully in the frontend. Make sure that the link text matches the one specified in the field link text.
    image
  • Then select image file, fill the alt text for test and check that the image has been rendered successfully in the frontend
    image
    image

Actual result BEFORE applying this Pull Request

You cannot select anything except images in custom fields,

Expected result AFTER applying this Pull Request

Now you can configure file types for custom field type media (wich is a bundle of media + text for alt + checkbox for empty alt). You can select a mp4 or pdf in your media custom field.

  • If image file has been selected - you can use alt text and empty alt fields. Image will render in frontend.
  • if audio or video file has been selected - <audio> or <video> tag will render in frontend.
  • if document file has been selected - you can use link text field for download link. Download link will render in frontend.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-5.3-dev labels Feb 25, 2025
@Septdir
Copy link
Contributor

Septdir commented Feb 26, 2025

I have tested this item ✅ successfully on 9a36d9b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

1 similar comment
@gug2
Copy link

gug2 commented Feb 26, 2025

I have tested this item ✅ successfully on 9a36d9b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@hans2103
Copy link
Contributor

I have tested this item ✅ successfully on 9a36d9b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@sergeytolkachyov
Copy link
Contributor Author

I have tested this item ✅ successfully on dff217a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

1 similar comment
@hans2103
Copy link
Contributor

I have tested this item ✅ successfully on dff217a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@sergeytolkachyov
Copy link
Contributor Author

@hans2103 can you test again, please?

@gug2
Copy link

gug2 commented Feb 26, 2025

I have tested this item ✅ successfully on dff217a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

1 similar comment
@viocassel
Copy link
Contributor

I have tested this item ✅ successfully on dff217a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@sergeytolkachyov
Copy link
Contributor Author

I have tested this item ✅ successfully on 8a2e00b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

1 similar comment
@gug2
Copy link

gug2 commented Feb 26, 2025

I have tested this item ✅ successfully on 8a2e00b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@web-eau-net
Copy link

I have tested this item ✅ successfully on 8a2e00b

Nice job!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@brianteeman
Copy link
Contributor

I am sorry but unless I misunderstand something this creates a very confusing UI in the admin and broken output in the front end and I dont see how any of you can have tested this successfully

image

image

image

image

@brianteeman
Copy link
Contributor

I have tested this item 🔴 unsuccessfully on 8a2e00b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.

@QuyTon QuyTon added the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label Jun 6, 2025
@brianteeman
Copy link
Contributor

brianteeman commented Jun 9, 2025

retesting this PR and I find that with this PR applied I am unable to upload an image into the root images folder. No error messages :(/ I can still upload to subdirectories

As soon as I revert this PR I can once again use media manager correctly.

This was an unrelated issue and solved elswhere

If {filename} shortcode is found - it will be replaced
added a `{filename}` short code processing
added wasted basename()
@sergeytolkachyov
Copy link
Contributor Author

From an accessibility perspective the default text for every link is "download" This can result in multiple links on the same page with the exact same details - which is an accessibility failure
An option might be to do it the way we do a read more link. eg Download < Filename >
Tagging @chmst for their a11y input

This accessibility failure must be resolved

image
Local pdf:
image
Remote pdf:
image
Frontend
image

@sergeytolkachyov
Copy link
Contributor Author

@rdeutz can I do anything else for this PR?

@sergeytolkachyov
Copy link
Contributor Author

@QuyTon can I do anything for this PR? I forgot make a separate branch for PR and then I can't do another one till this PR will be merged ((

@sergeytolkachyov
Copy link
Contributor Author

@QuyTon @rdeutz @brianteeman @laoneo Joomla 6.0.0 beta1 is coming in 2 days. It means a feature freeze for J6. This PR was succesfully tested and marked as update requested - so it should not be tested again. Is there anything else required for this PR? It has been opened in february...

@brianteeman
Copy link
Contributor

the people to tag are the release leads @softforge @Bodge-IT

@sergeytolkachyov
Copy link
Contributor Author

the people to tag are the release leads @softforge @Bodge-IT

Thank you!

@Bodge-IT
Copy link
Contributor

Hi @sergeytolkachyov, this only hit our radar on Sunday and we were locked by then. We had opinion this still needed resolutions.

@sergeytolkachyov
Copy link
Contributor Author

Hi @sergeytolkachyov, this only hit our radar on Sunday and we were locked by then. We had opinion this still needed resolutions.

Can I do anything for this pr or it will wait for j6.1?

@softforge
Copy link
Contributor

Hi @sergeytolkachyov, this only hit our radar on Sunday and we were locked by then. We had opinion this still needed resolutions.

Can I do anything for this pr or it will wait for j6.1?
We are looking into it and will have a decision tomorrow, but appreciate the work you have done to date, thank you

@sergeytolkachyov
Copy link
Contributor Author

We are looking into it and will have a decision tomorrow, but appreciate the work you have done to date, thank you

If you have any questions, feel free to ask me. I myself see several potential ways to improve consistency, but this will generally require discussion with other developers before implementation.

@softforge
Copy link
Contributor

Dear @sergeytolkachyov, first, thank you for all your work and patience so far.
We had a look through the code and see there are still some comments to be resolved, and then testing as there have been commits since the last tests.
Beta 1 has passed, so we cannot include it, but we would like to work with you over the next few weeks to get any comments satisfied and then test it in PBF if it's ready for that or straight after, and to help you get it into 6.1 early so you are not waiting 6 months for a decision but it could be one of the first things ready for the 6.1 managers to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Language Change This is for Translators PR-6.0-dev Updates Requested Indicates that this pull request needs an update from the author and should not be tested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.