User tests: Successful: Unsuccessful:
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.
file types
parameter was added to the field parameters during creation.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 valuevideos
and documents
for exampletypes
. Similar to Media field.File types
images
type is selected)Change image
images
and select a documents
or videos
or both of them. Save field params,Change file
alt text
and empty alt
fields, but new field link text
is presentdocuments
file types. The link text is download
by default. You can specify your own text.<video>
tag for selected file has been rendered successfully in the frontend for video
file types.<audio>
tag for selected file has been rendered successfully in the frontend for audio
file types.images
. So you have both images and non-images file types selected. Save field params.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
fieldChange file
. Check that you can choose both images and non-images file types.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
.You cannot select anything except images in custom fields,
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.
alt text
and empty alt
fields. Image will render in frontend.audio
or video
file has been selected - <audio>
or <video>
tag will render in frontend.document
file has been selected - you can use link text
field for download link. Download link will render in frontend.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
Status | New | ⇒ | Pending |
Category | ⇒ | Administration Language & Strings Libraries Front End Plugins |
Labels |
Added:
Language Change
PR-5.3-dev
|
I have tested this item ✅ successfully on 9a36d9b
I have tested this item ✅ successfully on 9a36d9b
I have tested this item ✅ successfully on dff217a
I have tested this item ✅ successfully on dff217a
I have tested this item ✅ successfully on dff217a
I have tested this item ✅ successfully on dff217a
I have tested this item ✅ successfully on 8a2e00b
I have tested this item ✅ successfully on 8a2e00b
I have tested this item ✅ successfully on 8a2e00b
Nice job!
I have tested this item 🔴 unsuccessfully on 8a2e00b
@sergeytolkachyov I have removed the successful test result you posted as it is assumed that the author would not submit something that didnt work and only tests from other people are valid
When testing this PR you need to actually test what the field produces and not the limited tests in the original post. In summary you might be able to select a document or a video but this field will NOT be able to display the document or video
When testing this PR you need to actually test what the field produces and not the limited tests in the original post. In summary you might be able to select a document or a video but this field will NOT be able to display the document or video
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45013.
I think all the successful tests were related to checking the very possibility of choosing a file type other than the image. in most cases, the standard layouts are redefined and in the frontend, the field is only required to provide the actual path to the file. and the desired layout is already determined by the developer in a specific override. nevertheless, I agree that the output of pdf or mp3 in the image tag will be incorrect. after all, audio and video can be output as a player, and pdf as <object>
, but you can't display docx like <object>
anymore. Such a variety of formats will complicate the logic of choosing a layout. would it be enough to output a file (not an image) as a download link?
For files you are correct it will just have to be a link
@brianteeman by default the field name
attribute is imagefile
, but if we are choosing a documents it will not an imagefile
by logic. But I think I will not change a field name because it will be a bc breakes.
Category | Administration Language & Strings Libraries Front End Plugins | ⇒ | Administration Language & Strings Layout Libraries Front End Plugins |
@gug2 @hans2103 @viocassel @web-eau-net @brianteeman check it please. Testing instructions has been updated.
I have tested this item ✅ successfully on 02796b9
still testing but looks good
I have tested this item ✅ successfully on 02796b9
👍
php warnings
Create a field for documents and in an article select a pdf and save
The following php warning
[27-Feb-2025 14:24:45 UTC] PHP Warning: mime_content_type(images/RL%20application%202017.pdf): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
Same for video
Feb-2025 14:24:08 UTC] PHP Warning: mime_content_type(images/sampledata/output.mp4): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
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
@viocassel how are you testing this?
php warnings
Create a field for documents and in an article select a pdf and save The following php warning
[27-Feb-2025 14:24:45 UTC] PHP Warning: mime_content_type(images/RL%20application%202017.pdf): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
I can't repeat the problem. Perhaps this is a MediaHelper and location issue on Windows.
Same for video
Feb-2025 14:24:08 UTC] PHP Warning: mime_content_type(images/sampledata/output.mp4): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
for video and audio I would expect the output to be a player not a download.
see
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
for video and audio I would expect the output to be a player not a download.
see
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
To do this, I will need to add new layouts. However, even for pdf, you will want to show them as an <object>
instead of a download link. Also, each file type may require its own additional data and settings specific to that particular file type. For videos, for example, the poster
attribute or specifying a file in a different format (mp4
, webm
etc.). This can greatly complicate the logic of choosing the output layout. I assumed that at this point, the very fact that you can choose something other than pictures is already a good thing. And the rest can be solved using override.
If a user selects an image and it displays an image then when they select a video they would expect it to display a video etc overrides are for customising the output with a layout is fine but it should work out of the box without an override.
If a user selects an image and it displays an image then when they select a video they would expect it to display a video etc overrides are for customising the output with a layout is fine but it should work out of the box without an override.
So we need a isVideo
, isDocument
and isAudio
methods for MediaHelper
... And check mime types too.
Because in plugins/fields/media/tmpl/media.php
I got a field params (with all file types configured for it) and field value. But I don't get the exact file type in the layout. Therefore, I need to define it, and then generate the necessary options for the render.
Alternatively, I can realize this check in the plugins/fields/media/tmpl/media.php
for now, and then add the isAudio
, isDocument
and isVideo
methods to MediaHelper
. After adding these methods, it will be possible to simplify the verification in the plugin layout.
If a user selects an image and it displays an image then when they select a video they would expect it to display a video etc overrides are for customising the output with a layout is fine but it should work out of the box without an override.
I added this. Check it please.
Testing instructions updated
@gug2 @web-eau-net @hans2103 @viocassel can you test again?
I have tested this item ✅ successfully on 887919c
still get php warning on non-image media
example
Mar-2025 12:37:12 UTC] PHP Warning: mime_content_type(images/rl.pdf): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
[03-Mar-2025 12:37:12 UTC] PHP Warning: mime_content_type(images/sampledata/output.mp4): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
still get php warning on non-image media
example
Mar-2025 12:37:12 UTC] PHP Warning: mime_content_type(images/rl.pdf): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99 [03-Mar-2025 12:37:12 UTC] PHP Warning: mime_content_type(images/sampledata/output.mp4): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
I can't reproduce this issue both on Windows local server and remote Linux server. This is my result for pdf
file.
This is for mp3
I came across with this issue only one time when the filename has contained a space. But this is not a problem of this PR, it is a MediaHelper problem that needs to be solved separately.
still get php warning on non-image media
example
Mar-2025 12:37:12 UTC] PHP Warning: mime_content_type(images/rl.pdf): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99 [03-Mar-2025 12:37:12 UTC] PHP Warning: mime_content_type(images/sampledata/output.mp4): Failed to open stream: No such file or directory in D:\repos\j51\libraries\src\Helper\MediaHelper.php on line 99
Can you reproduce this issue on other Joomla installation?
@QuyTon is there a ready-made preset of the Joomla code style for Php Storm? I use PSR-12 for formatting code, but at the same time, the alignment of the code does not occur as (as far as I understand) it is required in the Joomla core. This results in a lot of unnecessary commits.
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.