Closed (fixed)
Project:
Media duplicates
Version:
3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Feb 2020 at 17:40 UTC
Updated:
1 Apr 2026 at 15:00 UTC
Jump to comment: Most recent
Comments
Comment #2
nterbogt commentedThis module specifically does not address the cleanup. That's because it's a really hard problem to solve and dependent on your content structure and site setup.
The entity_usage module is pretty good, but doesn't cover all cases (like if you're embedding media through tokens). The workflow would be to find your references, clean them up, delete the old media items, and use the media duplicates module to track progress.
The purpose of this module is to help with detection and eventually to restrict the ability to create duplicates. We should also include some documentation about best practice for cleanup.
Comment #3
anybodyPerhaps we could implement this functionality as experimental submodule? So it could make progress while the key functionality is not affected? What do you think @nterbogt?
We'd be quite interested to help, as sooner or later we'll need this feature on client projects. @Christopher Riley it sounds like you could need the same? Would you also be interested to help or sponsor development?
What the submodule should be able to do is:
- Merge duplicates:
- Provide the UI to select duplicates and their representative media entity that should be kept and process the selected duplicates
The https://www.drupal.org/project/issues/auditfiles does similar things for Drupal files. We could have a look at the implementation and the UI / UX to not reinvent the wheel.
Things to consider:
Perhaps we can find a way to be helpful in 80-90% of the cases and simply let the user know what the module won't cover.
Even marking media entities as duplicate in bulk, not to be used anymore or for manual resolution, could be a good starting point!
Comment #4
anybodyComment #5
anybodyComment #6
anybodyAs written in #3356028: Offering to co-maintain Media duplicates this functionality should go into a submodule to separate this heavy part from the detection functionality.
Comment #7
anybodyComment #8
anybodyWe should first implement 3.x based on Custom Entity Type before starting that project, so we don't have to reengineer both.
Comment #10
grevil commentedComment #12
anybodyComment #13
anybodyComment #16
anybodyWhao generally the merging seems to work, but I didn't yet test references etc.!
Left some comments, but this seems a good starting point. Still a lot of work though.
Comment #17
anybodyShould definitely have tests in the end.
And let's use "unpublish" as alternative to deletion for duplicates, to be a bit safer...
Comment #18
grevil commentedComment #19
grevil commentedThat's it!
Comment #20
anybodyIMPRESSIVE work @grevil. I left some minor comments on the MR, but I think this is good to go as experimental!
We should then try to get feedback from the community and test this on local copies of projects where we need the merging feature ourselves!
Whao, I didn't expect this to happen, really really helpful and a good basis for future extensions. Please create follow-ups. I'd say also add a follow-up to allow plugins instead of the hard-coded methods currently to handle references on duplicates. Architecturally that would make a lot of sense!
Thinking about this: Do we need if-clauses or dependencies on the references we currently check hard-coded? Entity Reference and Media Library Embeds? Could this break somehow if the modules are not installed?
Another good reason for using plugins in the future for any kind of references. :)
https://www.drupal.org/project/dynamic_entity_reference is another good example for a possible plugin. Yeah I like the plugin architecture idea a lot, just picking up the duplicate media entities and handling them!!
Comment #21
grevil commentedI'll create the follow up issue you mentioned. Plugins will definitly matter, once we support media reference sources. Currently the form contains too much "working" code anyway.
We won't have a problem with entity_reference, since it is baked in core directly and the media_embed filter is tied to the media module and we already have a dependency on media. But we need to conditionally check for the filter module, good call!
Comment #22
grevil commentedOk, once the pipeline is green, I am going to merge this!
Comment #24
grevil commented