Maybe it can be solved at run-time. wp_get_attachment_image
says:
Returns an HTML image element representing an attachment file, if there is any, otherwise an empty string.
So, if the post meta is set, but an empty string is given, we should delete the post meta.
$default="<img src="" . get_stylesheet_directory_uri() . '/img/team-logo.png" />';
if ( get_post_meta( get_the_ID(), 'team_page_custom_image', true ) )
{
$get_img = wp_get_attachment_image( $post_meta_data['team_page_custom_image'][0], 'medium' );
if( !emtpy( $get_img ) )
{
echo $get_img;
}
else
{
delete_post_meta( get_the_ID(), 'team_page_custom_image' );
echo $default;
}
}
else
{
echo $default;
}
Or you can create a routine with get_posts()
(in some hook or Settings API) to iterate through all posts and check/delete orphans.