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)

| Comment | File | Size | Author |
|---|---|---|---|
| #31 | drupal-media-items-translate-items-in-modal-3266293-31.patch | 11.71 KB | alberto56 |
| #29 | drupal-media-items-translate-items-in-modal-3266293-29.patch | 11.72 KB | svenryen |
Issue fork drupal-3266293
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
mschudders commentedComment #3
mschudders commentedComment #4
mschudders commentedComment #5
mschudders commentedpatch has been tested against 9.3.5
Comment #6
joachim commentedThis is going to need UI work for all related Media editing issues.
Comment #7
mschudders commentedadded new patch which adds Access handling for media translate
Comment #8
mschudders commentedBug 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.
Comment #9
mschudders commentedForgot to copy a line to the patch.
Comment #10
mschudders commentedFixed an issue where the first item wasn't being a dropbutton.
Comment #12
mschudders commentedNew patch on 9.4.x with bug fix for "media/add/xxx"
On this page you had to press save twice. Now resolved.
Comment #13
mschudders commentedRemoved 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
Comment #15
oleh chemerys commentedHi @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.
Comment #16
oleh chemerys commentedWhoops, there was an issue with paths in the patch above, fixed it here.
Comment #17
jasonawantA 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,
If the "Hide non translatable fields on translation forms" option is enabled, when editing a the source language of the parent entity
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
Comment #18
jbabiak commentedAfter 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.
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.
Comment #19
jbabiak commentedRe 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
Comment #21
luksakComment #22
riyas_nr commentedAdding 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.
Comment #23
riyas_nr commentedComment #24
kriboogh commented#22 Also applies to 10.3.x
Comment #25
svenryen commentedI 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.
Comment #26
svenryen commentedComment #27
smustgrave commentedWe really do need changes in an MR for review.
Comment #28
joachim commentedThis 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.
Comment #29
svenryen commentedThe patch in #25 doesn't apply any more.
Attached is an updated patch.
Comment #31
alberto56 commentedHere 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.)