Is there a filter for when a Featured Image is set/unset or changed.
I need to delete transient data when the above occurs.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityIs there a filter for when a Featured Image is set/unset or changed.
I need to delete transient data when the above occurs.
The post featured image ID is stored as post metadata, so I would recommend hooking into the update_post_meta
or update_post_metadata
hooks, and then query the post meta for '_thumbnail_id'
being set.
You can use 'admin_post_thumbnail_html'. The simple function below will append 'This is a lovely image' to the image returned when you set the post featured image buut since $content is just an HTML string you can manipulate it in any way you want.
add_filter( 'admin_post_thumbnail_html', 'my_image_selected', 10, 2 );
function my_image_selected( $content, $post_id ) {
return $content . 'This is a lovely image';
}