Problem/Motivation

In https://www.drupal.org/project/drupal/issues/2985168 they are adding an edit button for media items on the node edit page.
This improves usability a lot.
This issue improves on that code and also adds a translate button.

This way you can edit and translate media entities on an edit form without navigating to the media overview page.

this patch needs this patch: https://www.drupal.org/files/issues/2022-02-18/2985168-117.patch (it builds/adapts on it further)
Please note that some items have been fixed like support for multiple domains and ajax refresh (fixed from patch 117)

Remaining tasks

- test
- test accessibility
- test usability
- create tests?

User interface changes

Adds a dropbutton to media entities so you can:
- remove
- edit
- translate (if necessary)

screenshot edit/translate on media entity

Issue fork drupal-3266293

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

Mschudders created an issue. See original summary.

mschudders’s picture

Issue summary: View changes
mschudders’s picture

StatusFileSize
new7.22 KB
mschudders’s picture

Issue summary: View changes
mschudders’s picture

Issue summary: View changes
StatusFileSize
new70.33 KB

patch has been tested against 9.3.5

joachim’s picture

This is going to need UI work for all related Media editing issues.

mschudders’s picture

added new patch which adds Access handling for media translate

mschudders’s picture

StatusFileSize
new10.51 KB

Bug fixing default language.
In our case ENG wasn't translated but it fall back as a default language due to the node language.

Patch attached to have correct language detection.

mschudders’s picture

StatusFileSize
new10.53 KB

Forgot to copy a line to the patch.

mschudders’s picture

StatusFileSize
new10.55 KB

Fixed an issue where the first item wasn't being a dropbutton.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mschudders’s picture

StatusFileSize
new10.93 KB

New patch on 9.4.x with bug fix for "media/add/xxx"

On this page you had to press save twice. Now resolved.

mschudders’s picture

Removed the "dropbutton" because it was causing to much issues.

Differences between:
- Editing media in settigns tray of a layout builder block
- adding media via "/media/add/xxx"
- editing media on a node edit form

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

oleh chemerys’s picture

StatusFileSize
new13.69 KB

Hi @mschudders,
Due to some platform limitations I have on the project, I can't update drupal core further than 9.3 atm, so I have rerolled the patch for that version. Thanks for the patch you created.

oleh chemerys’s picture

StatusFileSize
new13.79 KB

Whoops, there was an issue with paths in the patch above, fixed it here.

jasonawant’s picture

A quick review after using the following patches with Drupal 9.4.8:

I don't know if it needs stating, but the entity bundle's content translation option "Hide non translatable fields on translation forms" is not enabled.

When editing a translation of the parent entity when the media entity does not yet have a translation of the same language,

  • I see the media entity reference field display the media image thumbnail with edit and translate buttons above the preview.
  • Clicking the edit button allows me to edit the media entity's source translation
  • Clicking the translate button allows opens modal with modal title of "Create [Language] translation of [Media Name]" and create a translatiom of the media entity, e.g. removing image and uploading new image, etc.
  • However, after clicking save within the translate modal, the parent entity's media reference field widget is not updated to show the new translation. Instead, it continues to show the media entity's source translation. Is this expected behavior?
  • Reloading the page will update the preview with the new translation

If the "Hide non translatable fields on translation forms" option is enabled, when editing a the source language of the parent entity

  • I see the media entity reference field display the media image thumbnail with edit button above the preview.
  • I do not see a translate button above the preview. Is this expected behavior?

I'm not sure what to expect, but I thought I'd share my experience so far.
If the "Hide non translatable fields on translation forms" option is enabled, when editing a the source language of the parent entity

jbabiak’s picture

After getting the same experience as jasonawant from comments in #17

My solution for now was to use the patches from #17 then also enable Media Library Edit. (You have to enable 'Show edit button' in the reference field form widget). At this point I have an edit and translate button from patches in #17 (with issues such as not loading the correct language of media when on a translated node page) and another edit button from the media_library_edit module.

I then create a custom module to add css to my admin theme with hook_page_attachments to add css.

.js-media-library-widget input.edit-media {
  display: none;
}
.js-media-library-widget input.translate-media.button {
  display: block !important;
}

Im hiding the edit media button from the patches in #17, but still showing the translate media button when necessary (it only shows up when a media has no translation yet). Then using the media_library_edit edit media button as the only way to edit media on a node reference form. Messy, but seems to work.

jbabiak’s picture

StatusFileSize
new7.64 KB

Re rolling patch to work with latest in "2985168: Allow media items to be edited in a modal when using the field widget" : https://www.drupal.org/files/issues/2023-01-19/2985168-media-edit-modal-...

Seems to work with 9.4.x and 9.5.x .. but again still need the latest patch from issue #2985168

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

luksak’s picture

riyas_nr’s picture

StatusFileSize
new7.95 KB
new7.95 KB

Adding a re-rolled patch to make it compatible with "2985168: Allow media items to be edited in a modal when using the field widget": https://www.drupal.org/files/issues/2023-12-18/2985168-172.patch.

This patch works with Drupal 10.2.x.

riyas_nr’s picture

kriboogh’s picture

#22 Also applies to 10.3.x

svenryen’s picture

StatusFileSize
new8.2 KB

I couldn't use issue fork, since this code needs to be applied on top 2985168: Allow media items to be edited in a modal when using the field widget .

Attached is an updated patch that works with Drupal 11.2.5.

svenryen’s picture

Status: Postponed » Needs review
smustgrave’s picture

Status: Needs review » Needs work

We really do need changes in an MR for review.

joachim’s picture

Status: Needs work » Postponed

This is also still postponed!

> I couldn't use issue fork, since this code needs to be applied on top 2985168: Allow media items to be edited in a modal when using the field widget .

You can pull the branch from another MR into your fork, and then put your branch on top of it.

svenryen’s picture

StatusFileSize
new11.72 KB

The patch in #25 doesn't apply any more.

Attached is an updated patch.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

alberto56’s picture

Here is a version of #29 which is compatible with Drupal 11.3.2

(There was a tiny change replacing "todo:" with "todo" which caused the patch to not apply.)