Get DOM elements by tag name with DOMDocument::loadHTML and getElementsByTagName
Use this:
$img = $dom->getElementsByTagName('img')->item(0);
echo $img->attributes->getNamedItem("src")->value;
Use this:
$img = $dom->getElementsByTagName('img')->item(0);
echo $img->attributes->getNamedItem("src")->value;