Technical helper module to copy file / image field data to an existing Drupal Core Media field in the same entity / entities.

Only for developers (using drush), test carefully and take backups before use!

Condition:

You have one or multiple entity type bundles with a regular file / image field
(non-media, e.g. from a migration), and you want to migrate its instances
data into a media field.
The media field already exists and is empty or has to be created before using
this module. It should never have any values yet.

You do not want to use heavy weight migration.

How to use:

  • Add a media field, of the desired type, to the entity bundle you want to copy the file-data to.
  • Create a backup.
  • Install the module.
  • Run drush filefield-to-media:copy file-field-name media-reference-field-name media-bundle media-type-media-field-name entity-type [entity-bundle] [--no-reuse]
  1. `entity-bundle` is optional
  2. `--no-reuse` => This disables the reuse of existing media entities when available. Use this when you experience issues with the reuse hashes, you are not using the default media field configuration or when you need to use duplicates with different alt or title text.
  • Example: drush filefield-to-media:copy field_image field_image_media image field_media_image node
  • Alias is fftm and in the example above you can see the default command values, so running drush fftm would lead to the same outcome, as the example above.
  • Check if everything worked.
  • Delete the old file / image field if you don't need it anymore.
  • Alternative / similar modules:

    Development proudly sponsored by German Drupal Friends & Companies:

    webks: websolutions kept simple (https://www.webks.de)
    and
    DROWL: Drupalbasierte Lösungen aus Ostwestfalen-Lippe (OWL), Germany (https://www.drowl.de)

    Supporting organizations: 
    proudly developed this module for the community

    Project information

    Releases