joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.2] Media field: selectable folders

Open Fedik opened this issue 1 year ago • 20 comments

Summary of Changes

The PR add posibility to select directories usign the Media field. This is helpfull when the site have multiple Media adapters.

Testing Instructions

Run npm install.

Create custom field Media, Pick the directory in the "Directory" option.

Edit TinyMCE (plugin config) "Images Directory" (when "Images Drag and Drop" is On). And test TinyMCE drag and drop upload.

Actual result BEFORE applying this Pull Request

You able to pick only one of folder under /images

Expected result AFTER applying this Pull Request

You can pick any directory that available in the Media manager

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org: https://docs.joomla.org/Media_form_field_type
  • [ ] No documentation changes for docs.joomla.org needed
  • [ ] Pull Request link for manual.joomla.org: TBD
  • [ ] No documentation changes for manual.joomla.org needed

Fedik avatar May 30 '24 15:05 Fedik

Works fine for custom fields but what about in the media plugin? These are all subdirectories of /images

image

brianteeman avatar May 30 '24 16:05 brianteeman

@Fedik you could probably patch also this event: https://github.com/joomla/joomla-cms/blob/dfb572de83d16a25e7eee673b3875e18750e688b/administrator/components/com_media/resources/scripts/components/tree/tree.vue#L85 So selecting a folder on the left (disk/folder tree) could be also a valid way to select the folder

dgrammatiko avatar May 30 '24 16:05 dgrammatiko

@brianteeman I forgot it exists, should be good now. @dgrammatiko updated

Fedik avatar May 30 '24 16:05 Fedik

Is it possible to use something other than "types" as I am sure people will confuse it with "type"

brianteeman avatar May 30 '24 16:05 brianteeman

Is it possible to use something other than "types" as I am sure people will confuse it with "type"

That would be a b/c break so no

dgrammatiko avatar May 30 '24 16:05 dgrammatiko

Nope, unfortunately. It is what we already use https://github.com/joomla/joomla-cms/blob/bea594e404224ab404fe76ca55e5f9910227f183/libraries/src/Form/Field/MediaField.php#L237 For the Media field.

Fedik avatar May 30 '24 16:05 Fedik

ok fair enough. I searched for types = and got no hits - didn't think about types =

;)

brianteeman avatar May 30 '24 16:05 brianteeman

I also updated TinyMCE upload directory for "drag and drop", to use this feature.

Fedik avatar Jun 02 '24 11:06 Fedik

Nice work. I tested it with DPMedia and the FTP plugin, unfortunately when I select a folder from the FTP adapter, the field stays empty in the media custom field.

laoneo avatar Jun 05 '24 07:06 laoneo

@laoneo is right, this approach will never work for anything else other than the local filesystem. Maybe having dolder/path#adapterName://folder could work, but would need patches all over I guess

dgrammatiko avatar Jun 05 '24 07:06 dgrammatiko

Thanks for checking. I did not have a time to test with external adapters, and expected it works. I will update later

Fedik avatar Jun 05 '24 10:06 Fedik

There is a free version of DPMedia with the FTP adapter if you want to try it by yourself.

laoneo avatar Jun 06 '24 06:06 laoneo

I have checked. The field "Content - DPMedia" override configuration form for the Media Custom field (with own field for it). You need to disable this plugin then it will work.

After I disable that plugin it works for me Screenshot 2024-06-06_19-04-16

Fedik avatar Jun 06 '24 16:06 Fedik

I tested it, when it was disabled. The error I did, I didn't select the folder in the media manager, I just navigated to the folder I wanted to test and then hit the select button. Like in this screenshot: image

laoneo avatar Jun 07 '24 06:06 laoneo

I just navigated to the folder I wanted to test and then hit the select button

Hm, it also works for me. You navigating with Tree select or Breadcrumbs? Breadcrumbs does not do anything, but Tree should work.

Fedik avatar Jun 07 '24 06:06 Fedik

I clicked the folder inside the main area, where the folders are listed, not the tree or breadcrumbs.

laoneo avatar Jun 07 '24 07:06 laoneo

I clicked the folder inside the main area, where the folders are listed, not the tree or breadcrumbs.

So you clicked it twice to open? The media manager cannot handle it as "select".

There only one way to select something in media manager, is to tick the checkbox on the image/folder. And one addittional way for folders is to click the folder in Tree view.

Yeah, well, it can be confusing.

Fedik avatar Jun 07 '24 08:06 Fedik

I double clicked on the last folder inside the main area and then the select button. But I had to do it by being in the parent and then select the folder with the checkbox and not navigating into the folder and then click select.

laoneo avatar Jun 07 '24 11:06 laoneo

I have update PR, now the folder should be also selectable on "double click".

Fedik avatar Jun 07 '24 15:06 Fedik

This worked perfectly, also with navigation into another folder and with other adapters than the local one.

laoneo avatar Jun 20 '24 09:06 laoneo

I have tested this item :white_check_mark: successfully on 3223f82594c969c70c2c8bafbd39fcec9495d976

See my last comment


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

laoneo avatar Jul 22 '24 16:07 laoneo

I have tested this item :white_check_mark: successfully on 3223f82594c969c70c2c8bafbd39fcec9495d976


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

dgrammatiko avatar Jul 22 '24 17:07 dgrammatiko

I have tested this item :white_check_mark: successfully on 3223f82594c969c70c2c8bafbd39fcec9495d976


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

dgrammatiko avatar Jul 22 '24 17:07 dgrammatiko

RTC


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

Quy avatar Jul 22 '24 18:07 Quy

Just a note for the person that would merge this PR: ~~depending on the order of committing this PR and #43823 the one that would be second would have to update the extra event introduced in~~ please merge first this PR and then #43823.

dgrammatiko avatar Jul 22 '24 20:07 dgrammatiko

This feature is nice and I will merge it as soon as drone has passed. One thing which I find strange however is, that you can set it to a subfolder, but then you can still move up the folders and select a different folder. This is also present in the current implementation, but if I set it to folder X, I wouldn't expect to be able to upload in a parent folder of that.

Hackwar avatar Jul 23 '24 20:07 Hackwar

Thanks @Fedik for your contribution. :-)

Hackwar avatar Jul 23 '24 20:07 Hackwar