# File to Media Migration configuration for Article Media migration

id: mig_blog_post_media_step1
label: Blog Post Media Step 1

source:
    key: migration_source_db
    # Adapt it to your language
    # set null to migrate all languages into source language
    langcode: null
    # source language that will be used for the destination entity
    # if langcode is 'null' or 'und'
    source_langcode: en
    plugin: media_entity_generator_d7
    toggle_media_mapping: true
    entity_type: node
    bundle: blog_post
    d7_file_url: 'http://alert-black-rat.162-245-186-74.cpanel.site/sites/default/files/'
    field_names:
        - field_images
    # Using default language code unless other specified.
    langcode: 'und'

destination:
    plugin: entity:media

process:
    bundle:
        plugin: default_value
        default_value: image

    # Using the alt tag if available, else the file name.
    name:
        plugin: media_name
        source: file_name

    # This process plugin will skip the whole row if a existing media is found.
    existing_media_file:
        plugin: check_media_duplicate
        source: target_id

    # This process plugin will skip the whole row if a duplicate image is found.
    unique_file_id:
        plugin: check_duplicate
        source: target_id

    # Map the field image
    field_media_image/alt: alt
    field_media_image/title: title
    field_media_image/target_id:
        plugin: media_file_copy
        move: FALSE
        reuse: TRUE
        path: 'public://media/blog_post/'
        source: file_path

    langcode: langcode

    uid:
        plugin: default_value
        default_value: 1
