[ad_1]
[ad_2]
I have more than 100 posts that have the same featured image, and I'd rather replace them all with a single image and then delete the old images.
Goals
- Replace the old image with optimized image on all the posts that have the repeated image.
- Only have to update the alt and description in one place
- Free up storage space
Any tricks or plugins to do that?

There should be a filter for the featured image.
In fact seems to be this:
function use_specific_post_featured_image($html, $post_id, $post_image_id) {
// ID of the post whose featured image you want to use
$specific_post_id = 123;
// Get the featured image ID of the specific post
$specific_post_image_id = get_post_thumbnail_id($specific_post_id);
// If the specific post has a featured image, use it
if ($specific_post_image_id) {
// Get the HTML for the specific post’s featured image
$html = wp_get_attachment_image($specific_post_image_id, ‘full’);
}
return $html;
}
add_filter(‘post_thumbnail_html’, ‘use_specific_post_featured_image’, 10, 3);
Add it to functions.php
Yes, you can use Gato GraphQL’s free version (https://wordpress.org/plugins/gatographql/), run a query that sets the same featured image on all the posts:
“`gql
mutation {
posts {
setFeaturedImage(input: { mediaItemID: 1647 }) { # This is the ID of the image
status
errors {
__typename
…on ErrorPayload {
message
}
}
customPost {
…on WithFeaturedImage {
featuredImage {
id
src
}
}
}
}
}
}
“`
Docs: https://gatographql.com/guides/query/media
Without going the technical route, you can replace the old photo with the new one via FTP and use Thumbnail regenerate plugin to recreate the sizes.
Of course, this assumes the same image used is the same attachment ID each time.