Migrating image field to media entity reference on node

Created on 5 August 2022, almost 2 years ago
Updated 3 December 2023, 7 months ago

Problem/Motivation

The module page mentions

Image and file fields of the Drupal 7 source instance are migrated as media reference fields in Drupal 8|9.

The README mentions something slightly different:

Transforms image fields to media image fields.

My expectation is that an node image field on a Drupal 7 site with media module installed with an Image media type will become a media entity reference field in Drupal 8|9|10.

My actual result is that the image field remained an image field.The file_entity is correctly migrated to a media entity and files and images and entity references exist on the media entity. The files themselves are all referenced and migrated with the exception that image fields are still image fields e.g. field.storage.node.field_image is type image and target_type file rather than type entityreference and target_type media.

It is hard for me to understand exactly how the module works, and I tried to look at MigratePluginAlterer, but was confused as how any of that would migrate an image field to a media reference field on a node.

Steps to reproduce

Proposed resolution

Questions I would like to answer to figure out my next steps to be able to assert a successful migration:

* Is my expectation correct?
* If Yes, where in the code base can I find out where image fields should be migrated into media reference fields so I can hunt down what is going wrong with media_migration (or other modules combined on the site like commerce_migrate)?
* If No, is it possible to add "image: media_image" in upgrade_d7_field? Is there a module that does this?
* If No, what's the expectation for this module if fields remain in the "old way" and so any new uploads are not tied to media entities and the site cannot leverage the "new way" of Media Library?

Remaining tasks

API changes

N/A

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States mradcliffe USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mortona2k Seattle

    The default Article content type has field_image, which is an image file field. You need to delete that before generating the migration config or else it will get confused since the field storage already exists as the wrong type.

  • πŸ‡«πŸ‡·France erwangel

    My request is a bit different but concerns the same issue: is it possible to have field_image migration to media entity as an option ? In other words, is it possible to leave image_field as image (and migrate associated items without changing the field type) and only change file(image) field to media file ?

Production build 0.69.0 2024