Problem/Motivation
The problem is when adding new media, or editing existing media the form provided/altered by media_directories module is breaking my other modules integration (fe. focal_point). When I use the core media library ckeditor plugin, or field widget I do still have the desired functionality, when using the media_directory ckeditor entity browser plugin, or field widget browser I don't.
Steps to reproduce
Enable the focal point module, add an image field to a content type, in the form display select the field widget entity browser provided by media_directories. Add an image, see the inline entity form within the browser modal, after uploading an image you see the thumbnail but there is no crosshair that should be provided by the Focal point module.
Proposed resolution
Look into allowing functionality provided by other modules to the image widget within the media_directories add/edit media forms.
Remaining tasks
Make a decision
User interface changes
tbd.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | media_directories-3177821-16.patch | 3.34 KB | ckng |
| #15 | 3177821-show_real_image_widget-15.patch | 4.87 KB | stomusic |
| #9 | quickedit.png | 46.72 KB | dom. |
| #7 | 3177821-show_real_image_widget-7.patch | 4.03 KB | ytsurk |
Issue fork media_directories-3177821
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ytsurkDoes focal point work with a normal entity browser?
Comment #3
porchlight commented@ ytsurk Yes it does, and it works with the core Media Library field widget as well
Comment #4
ytsurkI see .. this is not entity browser related - but to our forms ;)
Comment #5
ytsurkRight now we only show the teaser of the image, and a limited image widget.
You always can use the Edit media in new tab to be able to use the image widget's functionality ...
We could offer a setting to have the image widget image displayed instead of only the preview. I'm a bit unsure about changing this by default, as we kind of split the img out of the image widget and put it aside ..
The setting could be named show default image widget and would remove the right sidebar with the preview.
Comment #6
ytsurkComment #7
ytsurkI discussed this with co-maintainer Rang501.
We do not want to change the current look and feel of the quick edit forms.
Thus, here an experimental setting, to show the real image widget. The preview link seems not to work (it opens, but does not close back to the modal form), but this can be configured away. I wonder how other functionality of this will work.
Still, we're open to make further adjustments, but so far for a beginning ..
Comment #8
ytsurkI want to flavor this with additional permissions.
Comment #9
dom. commentedI like it, but why in the scope of this issue and why not for every other supportted third-party module ?
Why not testing just if it evaluates to TRUE rather than isset ?
Tested on D9 with focal point widget: works fine : the saving take the new focal point in consideration as expected.

I wonder two points though:
- why such an option is needed rather then standard ? As a DX I expect the quick-edit to work that way: let me edit using the form mode I choosed.
- what permission flavoring do you expect ? If the user can't use focal point he won't see it. If he can't edit a media, he won't get the quickedit button. What new permission would you want added ?
Comment #10
rang501 commentedHi!
I do understand the need to use different crop functionality there, but the default should remain simple like it is in the core library.
What if we just check the image widget type and if it is different from the default, we would just show that widget? I think it is not that hard to do it?
One of the reasons we didn't want to show that widget is to hide the remove button (also the duplicated image) as the user shouldn't be able to change the image there. Maybe we could also add some custom code to search for that remove button from custom widgets?
An additional note about that modal problem - Drupal does have issues with showing multiple modals, the quick edit itself is inside modal, so opening another one could be an issue. As far as I know, nested modals are not supported. It is possible to open additional dialogs, but they may need a different z-index.
Comment #11
ytsurkDom, you're right 1. is not in the scope of this issue, let's move that here #3185914: Show a placeholder for disabled settings.
2. is needed as long as no update hook is written (a default value from ->get() would be clearer). It will be NULL after updating.
Regarding your questions:
The image field will not be shown if not added in the form mode. The image field is reduced to everything but the actual image (and remove button).
The setting is needed and EXPERIMENTAL imo as there could be broken functionality (fe. modal in modal).
I thought of a permission allowing to see the image widget, so enabling and permission is needed, that it can/needs be given to roles if desired.
@rang501 - I like the approach of showing it for non-default image widget (Maybe a permission [like Show non-default image widgets] would still be good in this case).
This is not linked to show the remove button (never saw the duplicate button). We still should disable it's access, no doubt about that.
We should not try to make the possible image widget modals work in any way imo, but maybe hide modal links inside it.
Comment #12
dom. commentedI am very sorry, I do not understand the issue with the image widget here.
In the screenshot I attached at #9, it shows the focal point being able to be used, and yet there is not "remove button" as well as no modal in modal.
I may be totally out here and I know my english is not very good, that is probably why I don't understand how this breaks things... I'm just saying that if you upload images with this library, but can't work out with focal point for instance in it, added to that you have disabled the link to standard media gallery in your toolbar, most novice DX will not find how to change the focal point of the image they just uploaded, and for experimented ones it takes forever to edit the media after creating it to change that focal point.
I am using this patch on prod and I can't find an issue with it at the moment. I would be happy to help only if I could understand what is expected to change :)
Comment #13
ytsurkThe clue is, that the media reference field is always shown (if existent in form mode) without the source-field-part
preview(what hides also the "image-widget") and without the remove button (we do not want to support uploads in the quick-edit mode). Neither we allow changing the language of a media in the quick-edit mode.Otherwise the alternative and title text would not be editable. Also custom fields added to the media will be shown.
Then, we show the media thumbnail in the left column.
Remember, we're not only talking images, but media (documents, remote videos (oEmbed) and all other possible - also contrib - media types).
So - that's why we should limit showing the "image-widget" to non-default (thumbnail already on the left, kind of UX) and media source type image only (there could be anything ..).
The remove button is hidden explicitly in MediaEditForm::buildEntityFormElement:
Comment #14
ytsurkComment #15
stomusicRe-roll for current patch
Comment #16
ckngRerolled, removed unrelated codes as mentioned in #9.
Comment #18
rang501 commentedFocal point is working in 3.x media browser.