I thinks, the best way to replace all your copyrighted images is to regex all your images in content.
I replace all images in content when I insert post programmatically in order created the demo from the live demo with copyrighted images:
$img_holder = get_template_directory_uri() . '/includes/demo-installer/images/placeholder.png';
$post_content = (string) preg_replace('/="([^"]*\.(?:png|jpeg|jpg|gif|bmp))"/', '="'.$img_holder.'"', (string) $content->encoded);
You can also do that for your post_meta.
To replace all feature thumbnails, I automatically add them with random placeholder image like this:
function add_attachment() {
global $add_post, $tt_post;
define('IMGPATH', get_theme_root() . '/theme/includes/demo-installer/images/');
$directory = get_template_directory_uri() . '/includes/demo-installer/images/';
$path = wp_upload_dir();
$images = glob(IMGPATH.'{*.jpg,*.JPG,*.png}', GLOB_BRACE);
foreach ($images as $image) {
$tt_post++;
$filename = basename($image);
$media_exists = get_page_by_title($filename, 'OBJECT', 'Attachment');
if ($media_exists == null) {
$add_post++;
if(wp_mkdir_p($path['path'])) {
$file = $path['path'] . '/' . $filename;
} else {
$file = $path['basedir'] . '/' . $filename;
}
$image_data = file_get_contents($image);
file_put_contents($file, $image_data);
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => sanitize_file_name($filename),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $file);
$attach_data = wp_generate_attachment_metadata( $attach_id, $file );
wp_update_attachment_metadata( $attach_id, $attach_data );
$attach_ids[] = $attach_id;
} else {
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
);
$query_images = new WP_Query( $query_images_args );
foreach ( $query_images->posts as $image) {
$image_url = wp_get_attachment_url( $image->ID );
if (strpos($image_url,'placeholder')!== false) {
$attach_id = $image->ID;
$attach_ids[] = $attach_id;
}
}
wp_reset_query();
}
}
$post_IDs = get_option('post_IDs');
$port_IDs = get_option('port_IDs');
$post_ids = array_merge((array)$post_IDs, (array)$port_IDs);
foreach ($post_ids as $post_id) {
$attach_id = $attach_ids[array_rand($attach_ids)];
set_post_thumbnail($post_id, $attach_id);
}
}
So, finally I just export my live demo and import it on a local host programmatically.
Then I just redownload the new demo with placeholder image.
It takes just 3-5min to create a formatted demo content without copyrighted images. This method works online and offline.