content summary of a post disappears If an images added at the beginning of the post. how to solve it?

You should probably use the core function the_excerpt() to avoid this problem. You can customize the length of your automated excerpt (see link below), so there’s really no reason to use the function you’ve used. This problem is probably caused by the str_replace funtion in your code.

http://codex.wordpress.org/Function_Reference/the_excerpt