Closed geerlingguy closed 4 years ago
In the custom module, it's kinda hacky, but it works:
/**
* Implements hook_migrate_prepare_row().
*/
function custom_migrate_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
$migration_id = $migration->id();
// Rewrite paths in node bodies.
if (in_array($migration_id, ['upgrade_d7_node_blog_post', 'upgrade_d7_node_page', 'upgrade_d7_node_project'])) {
$body = $row->getSourceProperty('body');
$body[0]['value'] = str_replace('sites/jeffgeerling.com/files', 'sites/default/files', $body[0]['value']);
$row->setSourceProperty('body', $body);
}
}
I just realized that all the embedded images on the site are pointing to
sites/jeffgeerling.com/files
(for example the image embedded in http://localhost/blog/2020/i-gave-away-my-books-free-and-sales-increased-4x). I need to make sure the migration accounts for that and rewrites all the content to make itsites/default/files
instead. Probably incustom.module
.