Preferred way to migrate IMCE on D8 to D8 Media library?

Created on 10 November 2020, about 4 years ago
Updated 5 March 2024, 10 months ago

We're using IMCE for some of our content types in D8 and it's worked very well but we'd now like to make those images available in the D8 media library. Is there a preferred way to migrate those from IMCE to the D8 media library? I believe I saw some mention of Media Bulk Upload β†’ in another thread. Is that the only way? Thanks for all your hard work!

πŸ’¬ Support request
Status

Active

Version

2.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States plato1123

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 mlncn Minneapolis, MN, USA

    This looks promising: https://www.drupal.org/project/drupal/issues/2835825#comment-15237330 πŸ“Œ Add d8 media migration Postponed

    And separate from that, we have successfully done it with an approach that doesn't use the migrate module, MigrationHelperFieldTransformations in the Migration Helpers β†’ module, used like this:

    function example_deploy_move_files_to_media() {
      $transformations = [
        [
          'node', // entity type
          ['field_attachments'], // old file/IMCE fields
          'field_media_attachments', // new media reference field
          ['page', 'forms_resources'], // bundles on the entity type that holds both the old file and new media reference fields
          'document', // the destination media bundle
          'field_media_document', // the destination file field on the media bundle
        ],
      ];
    
      \Drupal::logger('nchfa_custom')->log(LogLevel::INFO, "Transformation started.");
      foreach ($transformations as $transformation) {
        [$entity_type, $image_field_names, $media_field_name, $bundles, $media_entity_bundle, $media_target_field] = $transformation;
    
        /** @var \Drupal\migration_helpers\MigrationHelperFieldTransformations $field_transformations_service */
        $field_transformations_service = \Drupal::service('migration_helpers.field_transformations');
        $field_transformations_service->fieldToMediaEntity($entity_type, $image_field_names, $media_field_name, $bundles, $media_entity_bundle, $media_target_field);
    
        $source_fields = implode(', ', $image_field_names);
        \Drupal::logger('nchfa_custom')->log(LogLevel::INFO, "Data in image field(s) $source_fields of $entity_type entity moved to $media_field_name media reference field.");
      }
    }
    

    Don't worry about the references to image in the code it works for all files!

  • πŸ‡¨πŸ‡­Switzerland lomale@bluewin.ch Switzerland

    I come back on this, the other way round.
    I was using IMCE for our content types since D8 and it's worked very well, but now we'd like to make those images available in the D10 media library.
    There is also a problem, that the IMCE icon does not show anymore in the image field on D10

    Can someone help how you would solve this problem.
    Is there a preferred way to migrate those from IMCE to the D10 media library?

    Would I have to do this manually. not imaginable

    Thanks for your answers
    Lothar

Production build 0.71.5 2024