Heres a more simple version of your function:
<?php
add_filter( 'the_content', 'theme_videos_append_image' );
function theme_videos_append_image( $content ) {
global $post;
$upload_dir_arr = wp_upload_dir();
$static_image_url = $upload_dir_arr['baseurl'] . '/2017/11/upliftingscroll.jpg';
$tag = '<p><img src="' . $static_image_url . '" alt="" class="img-responsive" /></p>';
return has_tag( 'Videos', $post->ID ) ? $tag . $content : $content;
}
?>
Check if that is the most elegant solution for getting the image URL. Seems a bit odd to me.
The loop you’ve mentioned probably exists because in wp_update_post
the the_content
filter also may be applied. So if you want to stick to your solution try adding the post meta first and then updating the post content … but i don’t think this is necessary.