PHP look for image tag on content and append href to image

Can I look for all image tag in content and add a href="image" before the image? I want the image to open on click.

I have tried to get content using preg_match to append href before it. Below is my code:

preg_match_all('/<img(.*)+>/i',$content, $result);

foreach($result[0] as $k => $v){
       //still thinking about the append