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.

Command icon 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

porchlight created an issue. See original summary.

ytsurk’s picture

Does focal point work with a normal entity browser?

porchlight’s picture

@ ytsurk Yes it does, and it works with the core Media Library field widget as well

ytsurk’s picture

I see .. this is not entity browser related - but to our forms ;)

ytsurk’s picture

Status: Active » Needs work

Right 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.

ytsurk’s picture

Title: Support focal_point module » Show the image widget's preview instead of only the teaser
Issue summary: View changes
ytsurk’s picture

Version: 2.0.0 » 2.x-dev
Status: Needs work » Needs review
StatusFileSize
new4.03 KB

I 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 ..

ytsurk’s picture

Status: Needs review » Needs work

I want to flavor this with additional permissions.

dom.’s picture

Status: Needs work » Needs review
StatusFileSize
new46.72 KB
  1. +++ b/modules/media_directories_ui/media_directories_ui.module
    @@ -417,6 +424,15 @@ function media_directories_ui_form_media_directories_config_form_alter(&$form, F
    +  else {
    +    $form['media_directories_ui']['admin_toolbar_tools'] = [
    +      '#type' => 'fieldset',
    +      '#title' => t('Admin toolbar tools'),
    +      '#description' => t('We offer additional settings if the <em>admin_toolbar_tools</em>, submodule of <a href=":url">admin_toolbar</a> is installed and enabled.', [
    +        ':url' => 'https://drupal.org/project/admin_toolbar',
    +      ]),
    +    ];
    +  }
    

    I like it, but why in the scope of this issue and why not for every other supportted third-party module ?

  2. +++ b/modules/media_directories_ui/src/Form/AddMediaFormBase.php
    @@ -585,6 +585,10 @@ abstract class AddMediaFormBase extends FormBase {
    +      if (isset($show_real_image_widget)) {
    

    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 ?

rang501’s picture

Hi!

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.

ytsurk’s picture

Status: Needs review » Needs work

Dom, 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.

dom.’s picture

I 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 :)

ytsurk’s picture

The 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:

    // Remove original button added by ManagedFile::processManagedFile().
    if (!empty($element['remove_button'])) {
      $element['remove_button']['#access'] = FALSE;
    }
ytsurk’s picture

Version: 2.x-dev » 2.1.x-dev
stomusic’s picture

StatusFileSize
new4.87 KB

Re-roll for current patch

ckng’s picture

Status: Needs work » Needs review
StatusFileSize
new3.34 KB

Rerolled, removed unrelated codes as mentioned in #9.

rang501’s picture

Status: Needs review » Closed (outdated)

Focal point is working in 3.x media browser.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.