Problem/Motivation

In #2825215: Media initiative: Roadmap we mentioned that:

"When all the above is done, change Standard profile to ship with ER fields to Media entities instead of File/Image fields. Don’t force existing sites to migrate. They can keep using files as we don’t remove any of that from core. We can provide optional migration path later, but don’t require it until D9."

While not mandatory, existing sites might want to migrate to media entities as soon as possible, in order to take full advantage of the new api and functionalities.

Proposed resolution

We should provide a migration / upgrade path that would help existing sites move to the the new media-in-core paradigm.

Copying from #2930513-6: File/image field to media field migration, @juampynr has already begun work on such a migration path in contrib: https://www.drupal.org/project/media_migration

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Comments

marcoscano created an issue. See original summary.

berdir’s picture

While technically a migration actually makes sense, it imples your data is moved, which as far as I understand and how media works in contrib is *not* what is happening at all.

This also only partially the right issue, but wanted to post it somewhere

Right now, the structure looks like this for an Article with images:

[Node] -> {ImageField with Image Widget] -> [File]

With Media, this is how it works right now in Contrib (usually):

[Node] -> {EntityReference with IEF/EntityBrowser Widget] -> [Media] -> {ImageField with ImageWidget} -> [File]

So nothing is *replaced*, we only add more things in between. You still use image fields, you still use the image widget (although that is often replaced with Dropzone in EntityBrowser, but that's optional, adding a new media through /media/add or editing it shows the ImageWidget)

Core will not add IEF/EntityBrowser/Dropzone in the near future but will instead implement its own new widget that will basically do the same, create a Media Entity that references a File in an ImageField/ImageWidget. You don't see that when editing the Article with the fancy new Widget, but when editing the Media Element itself, we still need a normal Image Widget in a normal Image Field.

That considered, I don't see how we could actually deprecate or even remove Image/File fields/widgets, internally, we still need them just as much as we did before? There will always be the need for a field/widget on media entities and there are also valid use cases for using them on other entities, when you on purpose don't want stuff to be in your media library for example (e.g. upload fields on contact forms or on other entities that normal users can see/use).

xjm’s picture

Status: Active » Postponed

So, this duplicates part of the scope of #2835825: Add d8 media migration (I think) but that issue includes actually adding the Migration API for Media as well. I guess we can postpone this on that.

xjm’s picture

Re: #2, seems like this discussion is coming up across a number of the child issues. There is #2862458: [META] Once media is enabled, having the File, Image and Media reference fields all listed is confusing, and then the handwavy "Eventually" section of #2825215: Media initiative: Roadmap. And regarding widgets, #2831940: Create file field widget on top of media entity.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wim leers’s picture

See #2930513-6: File/image field to media field migration, where @juampynr points to contrib code doing this.

Also, what is the relation of this issue to #2930513: File/image field to media field migration? It seems like #2930513 is a duplicate of this issue?

phenaproxima’s picture

Issue summary: View changes

It seems to be a duplicate, yes. I'm closing that one in favor of this one, since this issue seems to have been more active.

wim leers’s picture

So #2930513 was closed as a duplicate of this. Key information that was there but not here is @juampynr's #2930513-6: File/image field to media field migration, where he pointed to #3044434: Migrate image fields to media image fields — the Media Migration contrib module has code for this!

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Status: Postponed » Active

Going to unpostpone this - I've just switched a site from old image fields to media fields, and wrote a custom post update to do it in the end. If we're not going auto-update people, and I agree we can't, then we might just need an 'official' documentation page for this.

Because any update essentially 'copies' references from one field to another, while it's possible to use migrate, a custom update or drush command with old_field and new_field arguments would also do the job.

There are a couple of solutions in contrib:

https://www.drupal.org/project/image_field_to_media

https://www.drupal.org/project/migrate_file_to_media

(Also linking https://www.drupal.org/project/convert_entity_media_embed which solves a different but related issue).

The high-level view of how my custom update worked is similar to https://www.drupal.org/project/image_field_to_media

1. Create a new media field to hold the references from the old field.
2. In the post update, take the values of the old field, create a media entity, append it to the values of the new field + save the parent entity.
3. I left the old field in place (but hidden in form/display modes) since this provides an easy way to audit before/after, it can then be deleted later manually.

One issue I realised though, is that for file fields, we don't have an equivalent of the 'list' checkboxes, this is going to be a challenge for anyone with hidden files. The 'list' checkboxes tended to be used by people uploading images to those then embedding them in the node body (before media embed and similar existed), but that old content is still out there.

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.

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.

quietone’s picture

Issue tags: +migrate

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.

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.