How to make plugin work in each template in wordpress

You would have to put your code in your question into a function. Maybe something like function wpse_91897_get_image() { }. Then try the code below. I haven’t tested this but it should work.

function wpse_91897_display($content) {
    global $single;

    $output = wpse_91897_get_image();

    if (is_single()) {
        return $content . $output;
    } else {
        return $content;
    }
}

Then you would add a filter to call the functions for the content.

add_filter('the_content', 'wpse_91897_display');

Then add some CSS to position and style it. It will show up under the content on your post.