0

I have to migrate a website from Drupal 7 to Drupal 9. My Drupal 7 files were located in this directory : sites/mywebsite/files In Drupal 9, files will be located in this directory : sites/default/files

While paths are automatically managed by media module in ckeditor in D9, the path for every file is still sites/mywebsite/files/myfile.pdf. I don't know where to change it.

How to fix this?

Thanks

1 Answer 1

0

You can achieve that by adopting the below snippet to your use case.

source:
  constants:
    PROFILE_PICTURES_FILE_DIRECTORY: 'public://profile_pictures/'

process:

  profile_picture_destination_filename_base:
    -
      plugin: concat
      source:
        - title
        - field_account_id
      delimiter: '-'

  profile_picture_destination_filename:
    -
      plugin: callback
      callable: basename
      source: field_profile_picture # This is the photo URL column.
    -
      plugin: callback
      callable: ucfirst

  profile_picture_destination_full_path:
    -
      plugin: concat
      source:
        - constants/PROFILE_PICTURES_FILE_DIRECTORY
        - '@profile_picture_destination_filename_base'
        - '@profile_picture_destination_filename'
    -
      plugin: urlencode

  profile_picture_source_image_path:
    -
      plugin: urlencode
      source: field_profile_picture # This is the photo URL column.
  uri:
    plugin: file_copy
    source:
      - '@profile_picture_source_image_path'
      - '@profile_picture_destination_full_path'
    file_exists: 'rename'
    move: FALSE
1
  • During migration, files are well copied in the destination path /sites/default/files. The issue occurs when medias are integrated within ckeditor. <drupal-media data-entity-type data-entity-uuid> generates a path with the old location : sites/mywebsite/files/myfile.pdf . I'm currently using a filter to replace mywebsite by default, but I don't think it's the better solution.
    – Alexander
    Commented Feb 5, 2021 at 10:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.