Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/UsesContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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'),
Expand Down