Skip to content

Commit

Permalink
Save status for each broken image
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Jul 3, 2023
1 parent 5ac93ba commit e5d19b8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Checks/Content/BrokenImageCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,25 @@ public function validateContent(Crawler $crawler): bool
return true;
}

$links = [];

$content = collect($content)->filter(fn ($value) => $value !== null)
->map(fn ($link) => addBaseIfRelativeUrl($link, $this->url))
->filter(fn ($link) => isBrokenLink($link))->toArray();
->filter(fn ($link) => isBrokenLink($link))
->map(function ($link) use (&$links) {

$remoteStatus = getRemoteStatus($link);

$links[] = $link . ' (status: ' . $remoteStatus . ')';

return $link;
});

$this->actualValue = $content;
$this->actualValue = $links;

if (count($content) > 0) {
$this->failureReason = __('failed.content.broken_images', [
'actualValue' => implode(', ', $content),
'actualValue' => implode(', ', $links),
]);

return false;
Expand Down

0 comments on commit e5d19b8

Please sign in to comment.