You are here

wordpress_attachments.yml in WordPress Migrate 8.3

migrations/wordpress_attachments.yml

File

migrations/wordpress_attachments.yml
View source
  1. # @todo: Do not use - will be refactored when https://www.drupal.org/node/2695297 is committed.
  2. # @see https://www.drupal.org/node/2742269
  3. id: wordpress_attachments
  4. label: Import files from WordPress XML
  5. migration_tags:
  6. - WordPress
  7. source:
  8. plugin: url
  9. data_fetcher_plugin: http
  10. data_parser_plugin: xml
  11. item_selector: '/rss/channel/item[wp:post_type="attachment"]'
  12. constants:
  13. file_dest_uri: 'public://featured_images'
  14. fields:
  15. -
  16. name: title
  17. label: Attachment title
  18. selector: title
  19. -
  20. name: post_id
  21. label: Unique content ID
  22. selector: wp:post_id
  23. -
  24. name: content
  25. label: Description of the file
  26. selector: content:encoded
  27. -
  28. name: excerpt
  29. label: Caption for the file
  30. selector: excerpt:encoded
  31. -
  32. name: pubDate
  33. label: Publish date of the file
  34. selector: pubDate
  35. -
  36. name: post_date
  37. label: Post date of the file
  38. selector: wp:post_date
  39. -
  40. name: creator
  41. label: Username of the content creator
  42. selector: dc:creator
  43. -
  44. name: attachment_url
  45. label: Full URL of the file on the source system
  46. selector: wp:attachment_url
  47. -
  48. name: alt
  49. label: Alt text for an image
  50. # @todo: Make sure wp:meta_key is _wp_attachment_image_alt
  51. # @link https://www.drupal.org/node/2742275
  52. selector: wp:postmeta/wp:meta_value
  53. ids:
  54. post_id:
  55. type: integer
  56. process:
  57. # uid mapping is dynamically generated.
  58. destination_file:
  59. plugin: callback
  60. callable:
  61. - '\Drupal\Core\File\FileSystem'
  62. - basename
  63. source: attachment_url
  64. filename: '@destination_file'
  65. destination_full_path:
  66. -
  67. plugin: concat
  68. delimiter: /
  69. source:
  70. - constants/file_dest_uri
  71. - '@destination_file'
  72. -
  73. plugin: urlencode
  74. uri:
  75. plugin: file_copy
  76. source:
  77. - attachment_url
  78. - '@destination_full_path'
  79. created:
  80. plugin: callback
  81. source: post_date
  82. callable: strtotime
  83. changed: '@created'
  84. status:
  85. plugin: default_value
  86. default_value: 1
  87. destination:
  88. plugin: entity:file
  89. # Dependencies are dynamically generated.
  90. migration_dependencies: {}