Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

File-Field to Media-Field

Security covered Under active development 34 sites

This module is a developer tool that copies data from existing file or image fields into a Drupal Core Media field on the same entity. It's useful for migrating content without needing to perform a full site migration.

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)

    Ask your assistant about File-Field to Media-Field

    Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

    Depends on

    Dependencies of the latest stable release

    No dependencies recorded for this project.

    Required by

    Tracked projects that depend on this one

    No tracked projects depend on this one yet.

    Activity

    Tracked releases
    2
    Tracked since
    Jan 2024
    Latest release
    2 years ago
    Releases (12 mo)
    0
    Maintenance
    Dormant

    Releases

    Version Type Core PHP Release date
    1.0.0-beta1 Pre-release 8–10 Feb 1, 2024
    1.0.0-alpha2 Pre-release 8–10 Jan 31, 2024