Replace image src with php dom

$dom = new DOMDocument();
$dom->loadHTML($data['description']);
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
$old_src = $image->getAttribute('src');
$new_src = 'image/products/newimage.jpg';
$image->setAttribute('src', $new_src);
$image->setAttribute('data-src', $old_src);
}
$data['description'] = $dom->saveHTML();

Need Help With Code?