If anyone needs a solution, I fixed this myself using Elementor’s code for their “Tools > Replace URL” function. Put the code below at the end of your ocdi_after_import function and replace <YOUR_URL_GOES_HERE> with the source URL where your assets are pulled from, WITHOUT the slash at the end:
/**
* Replace URLs in content created with Elementor
*/
if ( class_exists( '\Elementor\Plugin' ) ) {
global $wpdb;
$old_url = '<YOUR_URL_GOES_HERE>';
$new_url = get_site_url();
$escaped_from = str_replace( '/', '\\/', $old_url );
$escaped_to = str_replace( '/', '\\/', $new_url );
$meta_value_like = '[%'; // meta_value LIKE '[%' are json formatted
$rows_affected = $wpdb->query(
$wpdb->prepare(
"UPDATE {$wpdb->postmeta} " .
'SET
meta_value
= REPLACE(meta_value
, %s, %s) ' .
"WHERE meta_key
= '_elementor_data' AND meta_value
LIKE %s;",
$escaped_from,
$escaped_to,
$meta_value_like
)
);
if ( false === $rows_affected ) {
throw new \Exception( 'An error occurred while replacing URL\'s.' );
}
// Allow externals to replace-urls, when they have to.
$rows_affected += (int) apply_filters( 'elementor/tools/replace-urls', 0, $old_url, $new_url );
\Elementor\Plugin::$instance->files_manager->clear_cache();
}