Media form field - Open media manager with specific settings

55 views
Skip to first unread message

Mind gem

unread,
Jun 25, 2016, 6:07:00 AM6/25/16
to Joomla! General Development
What I try to get is the media form field to open with:

- A user specific directory. It has subfolders in it which should be allowed to open. One shouldn't be able to navigate above the own directory
- Add a filter for directory files to disclude files starting with "thumb_"
- Remove the file upload and image url form the modal window

I was trying to create a layout override for the form field within com_media by adjusting the url from:

index.php?option=com_media&view=images&tmpl=component

to:

index.php?option=com_media&view=images&&layout=custom&tmpl=component

In my copy of the media form field layout (made custom field mediacustom and included that in my form.xml).

Any thoughts how to achieve the above with the build in Media Manager?

piotr_cz

unread,
Jun 25, 2016, 12:18:43 PM6/25/16
to Joomla! General Development
I've coded a system plugin, which ads a subfolder to Media manager parameter: image folder based on user name or group name.
So yes, it's possible.

There is new version of media manager in the working: https://github.com/joomla-projects/media-manager-improvement/, you may check if such features are built in but don't count on having it in Joomla GA release any time soon.

Mind gem

unread,
Jun 25, 2016, 1:42:44 PM6/25/16
to Joomla! General Development
For the layout override I made a default (copy of the original one) in my template and made an if-statement on the assets that is provided in the media link. So that seems to work out the override and removing file upload options.

Leaves met with the filtering of thumb_ files and the user image folder.

@piotr -> Would you hint me what event you used for this?




Op zaterdag 25 juni 2016 18:18:43 UTC+2 schreef piotr_cz:

piotr_cz

unread,
Jun 25, 2016, 4:49:36 PM6/25/16
to Joomla! General Development
I've used onAfterRoute event to trigger plugin as soon as possible but have access to media component parameters.
There are few choices for strategies to determine subfolder name (username, user id, accesslevel, domain, group_id), creating subfolder if it doesn't exists and just

$media_params = JComponentHelper::getParams('com_media');
$current
= $media_params->get('image_path', 'images');
$folder
= $current . '/' . $subfolder;
$media_params
->set('image_path', $folder);

same for file_path

However I never run this in production, as project had to be put on hold.

I can send you whole plugin by email if you are interested.

Mind gem

unread,
Jun 26, 2016, 4:09:44 AM6/26/16
to Joomla! General Development
Thanks.

Managed to override the com_media views by copying them to my templates folder. I added a if statement on the asset referring my component name to keep for other components the original default view
Managed to link the right directory using the suggestion of piotr_cz to use a system plugin. This allowed me to set the default basedir's and with make is user depended by using $user object



Op zaterdag 25 juni 2016 22:49:36 UTC+2 schreef piotr_cz:

Allon Moritz

unread,
Jun 26, 2016, 4:43:01 AM6/26/16
to joomla-de...@googlegroups.com
In custom fields we are doing it that way https://github.com/joomla-projects/custom-fields/pull/161/files. Perhaps it helps.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages