<?php
$string = 'wefwef dfwefrf we<h1>sodm</h1> <img src="some.jpg" />';
$pattern = '/(<img .+?\/?>)/';
$replacement = '<div class="my-div">$1</div>';
?>
PD9waHAKJHN0cmluZyA9ICd3ZWZ3ZWYgZGZ3ZWZyZiB3ZTxoMT5zb2RtPC9oMT4gPGltZyBzcmM9InNvbWUuanBnIiAvPic7CiRwYXR0ZXJuID0gJy8oPGltZyAuKz9cLz8+KS8nOwokcmVwbGFjZW1lbnQgPSAnPGRpdiBjbGFzcz0ibXktZGl2Ij4kMTwvZGl2Pic7CmVjaG8gcHJlZ19yZXBsYWNlKCRwYXR0ZXJuLCAkcmVwbGFjZW1lbnQsICRzdHJpbmcpOwo/Pg==