When we migrate a wysiwyg content whose contains a file, there is some problems :

  1. If the source view_mode does not exist in the D8 version, we have an error while displaying the file (data-entity-embed-display) : to solve this we can allow to use a mapping array between the old and the new view mode in the migration file
  2. If the source file fid was not preserved during the migration we need to update it into the wysiwyg (data-entity-id) : for this we can allow to use a migration id array into the migration file so we can use the migration lookup system for this
  3. The pattern /file/{fid}/download?token={token} needs also to be updated with new fid and token : we can also use the migration lookup system as well as the getDownloadToken() method

Example of use :

process:
  field_body:
    -
      plugin: media_wysiwyg_filter
      view_mode_matching:
        default: full
      media_migrations:
        - upgrade_d7_file_entity_archive
        - upgrade_d7_file_entity_image
        - upgrade_d7_file_entity_publication
      file_migrations:
        - upgrade_d7_file
      source: field_user_texte

Comments

caco_d25 created an issue. See original summary.

caco_d25’s picture

Configuration file example :

process:
  field_title:
    -
      plugin: get
      source: field_title
  field_body:
    -
      plugin: media_wysiwyg_filter
      source: field_body
      matching:
        - default: full
        - teaser: accroche
      migrations:
        - upgrade_d7_file_entity_image
        - upgrade_d7_file_entity_local_video
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: multiblock_image_wysiwyg
migration_dependencies:
  optional: {  }
  required:
    - migrate_plus.migration.upgrade_d7_file_entity_image
    - migrate_plus.migration.upgrade_d7_file_entity_local_video
caco_d25’s picture

Status: Active » Needs review
nixou’s picture

This is working for me.

I made some cleaning and add a new feature to update pattern "/file/{fid}/download?token={token}" with the new fid and token.

nixou’s picture

Title: Mapping of datas for image in wysiwyg during migration D7 to D8 » Mapping of fid, view mode and download token for file in wysiwyg during migration
Issue summary: View changes
nixou’s picture

StatusFileSize
new3.72 KB
new4.58 KB

Oops, the patch do not apply, I created a new one that apply correctly.

nixou’s picture

nixou’s picture

During my tests I got an error in case the file referenced by the wysiwyg no longer exists on the source site.

Indeed the file does not exist anymore, it is not migrated and the File::load does not work.

I added a condition to check that the file is loaded before trying to retrieve its new token.

nixou’s picture

I didn't pay attention but for the two features "embed update" and "download link update" in wysiwyg, we don't rely on the same migrations.

In the first case we have to use the media migration since we want to indicate a media identifier.
And in the second case we have to base ourselves on the migration of the files since we want to indicate a file identifier.

I have updated the code in this sense and to allow two sets of migration files.

nixou’s picture

nixou’s picture

Issue summary: View changes
nixou’s picture

StatusFileSize
new3.95 KB
new505 bytes

I changed the function from private to protected to allow to extend easily the plugin.

steinmb’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.x-dev
Assigned: caco_d25 » Unassigned

If you want other to review it. It probably should not be assign to you. Also make sure the patch apply cleanly against dev.

mortona2k’s picture

Status: Needs review » Reviewed & tested by the community

I have been working on a migration with this patch and it seems to work. This adds some very important features for these migrations.

  • juampynr committed 8a6592c on 8.x-1.x authored by Nixou
    Issue #3096596 by Nixou, caco_d25: Mapping of fid, view mode and...
juampynr’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks!

  • huzooka authored 863bc54 on 8.x-1.x
    Issue #3128540 by huzooka: Follow up for #3096596: MediaWysiwygFilter...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.