// Create a DOMDocument
$dom = new DOMDocument();
// Load html including utf8, like Hebrew
$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
// Create the div wrapper
$div = $dom->createElement('div');
$div->setAttribute('class', 'responsive-img');
// Get all the images
$images = $dom->getElementsByTagName('img');
// Loop the images
foreach ($images as $image)
{
//Clone our created div
$new_div_clone = $div->cloneNode();
//Replace image with wrapper div
$image->parentNode->replaceChild($new_div_clone,$image);
//Append image to wrapper div
$new_div_clone->appendChild($image);
}
// Save the HTML
$html = $dom->saveHTML();
return $html;