Skip to content

Commit

Permalink
Add/replace domain by link rel=preload images
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Tepper committed May 13, 2024
1 parent 32cd85e commit 7df0eaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Classes/Content/Scraper/Html/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class Image extends AbstractHtmlScraper implements ScraperInterface
public function scrape(string $content): ?Collection
{
return $this->getAssets('img', 'src', $content)
->merge($this->getAssets('image', 'href', $content));
->merge($this->getAssets('image', 'href', $content))
->merge($this->getAssets('link', 'href', $content, [
'type' => 'image/webp',
'type' => 'image/png',
'type' => 'image/jpeg',
'type' => 'image/gif',
]));
}
}
4 changes: 2 additions & 2 deletions Tests/Content/Scraper/Html/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public function testScrape(): void

$assetFactory = $this->getMockBuilder(Factory::class)->getMock();
$assetFactory
->expects($this->exactly(2))
->expects($this->exactly(3))
->method('createAssetsFromPaths')
->with(['uploads/tx_templavoila/example.gif'])
->willReturn(new Collection());

$attributeExtractor = $this->getMockBuilder(XmlTagAttribute::class)->getMock();
$attributeExtractor
->expects($this->exactly(2))
->expects($this->exactly(3))
->method('getAttributeFromTag')
->willReturn([
'paths' => ['uploads/tx_templavoila/example.gif'],
Expand Down

0 comments on commit 7df0eaf

Please sign in to comment.