Distinguish between page and post in function

By using post id you can get post type of current post/page. try below code. i have tested and it is working fine for me.

add_filter( 'admin_post_thumbnail_html', 'foo',10,3 );
function foo( $content, $post_id, $thumbnail_id ) {
   if ( get_post_type( $post_id ) == 'page' ) {
        $content="<p>foobar</p>" . $content;
     }
    else{
        $content="<p>barfoo</p>" . $content;
     }
     return $content;
}

Let me know if this works for you!