0

I've been working on a D7 to D9 migrate project, and encountered an issue around field_image's alt value.

The D7 site does not have all the field_image alt tag setup, so we'd like to use the imported Node Title as a replacement if the value was empty.

The migration config file works, all other fields are imported perfectly. Just the alt tag didn't make use of the replacement of '@title' instead (I saw other usage of @ syntax on other migration config files). All I saw was @title string within my alt field after importation.

How should I make it work? Thanks!

config/sync/migrate_plus.migration.upgrade_d7_node_complete_article.yml

langcode: en
status: true
dependencies: {  }
id: upgrade_d7_node_complete_article
class: Drupal\node\Plugin\migrate\D7NodeTranslation
field_plugin_method: null
cck_plugin_method: null
migration_tags:
  - 'Drupal 7'
  - Content
migration_group: migrate_drupal_7
label: 'Node complete (News)'
source:
  plugin: d7_node_complete
  node_type: article
process:
  nid:
    -
      plugin: get
      source: tnid
  vid:
    -
      plugin: get
      source: vid
  langcode:
    -
      plugin: default_value
      source: language
      default_value: und
  title:
    -
      plugin: get
      source: title
  field_image:
    -
      plugin: sub_process
      source: field_image
      process:
        target_id: fid
        alt:
          plugin: default_value
          source: alt
          default_value: '@title'
        title: title
        width: width
        height: height
destination:
  plugin: 'entity_complete:node'
  translations: true
  default_bundle: article
migration_dependencies:
  required:
    - upgrade_d7_user
    - upgrade_d7_node_type
    - upgrade_language
  optional:
    - upgrade_d7_field_instance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.