I have a multisite in which more than 100 sites. I want to raise the site for development. Pictures decided not to download because they take up too much space. I want to replace pictures with a placeholder using the console:
wp search-replace "prod-image.jpg" "placeholder.jpg" wp_312_post* --network
After this I delete all image sizes frow DB
$images = $wpdb->get_results(
'SELECT pm.post_id, pm.meta_value FROM ' . $wpdb->posts . ' as p
LEFT JOIN ' . $wpdb->postmeta . ' as pm ON p.ID = pm.post_id
WHERE p.post_type = "attachment"
AND pm.meta_key = "_wp_attachment_metadata"'
);
foreach ( $images as $key => $image ) {
$image_meta = unserialize( $image->meta_value );
$image_meta['sizes'] = [];
update_post_meta( $image->post_id, '_wp_attachment_metadata', $image_meta );
}
This works, but for this I need to know all the image names. This process takes too much time. Anyone have an idea how to speed up migration?
P.S. Replace through WordPress hook not to offer, because the templates use a lot of different functions for displaying images and most of them are custom.