diff --git a/src/UsesContent.php b/src/UsesContent.php index afcf472..dcd1018 100644 --- a/src/UsesContent.php +++ b/src/UsesContent.php @@ -529,9 +529,13 @@ public function images(): array $images = $this->filter('//img')->images(); /** @var \Symfony\Component\DomCrawler\Image $image */ - foreach ($images as $image) { - $result[] = $image->getUri(); - } + foreach ($images as $image) { + $node = $image->getNode(); + if ($node) { + $result[] = !empty($node->getAttribute('data-src')) ? $this->makeUrlAbsolute($node->getAttribute('data-src')) : $image->getUri(); + } + } + return $result; } @@ -551,7 +555,7 @@ public function imagesWithDetails(): array // Collect the URL and commonly interesting attributes $result[] = [ // Re-generate the proper uri using the Symfony's image class - 'url' => (new DomCrawlerImage($image, $this->currentBaseHost()))->getUri(), + 'url' => !empty($image->getAttribute('data-src')) ? $this->makeUrlAbsolute($image->getAttribute('data-src')) : (new DomCrawlerImage($image, $this->currentBaseHost()))->getUri(), 'alt' => $image->getAttribute('alt'), 'width' => $image->getAttribute('width') === '' ? null : $image->getAttribute('width'), 'height' => $image->getAttribute('height') === '' ? null : $image->getAttribute('height'),