From cdd749d06e9e9741b50888980c3b1fb3a23e465f Mon Sep 17 00:00:00 2001 From: Bas van Dinther Date: Tue, 26 Nov 2024 13:58:41 +0100 Subject: [PATCH] Handle failed image size check gracefully and return default values (#73) --- src/Checks/Content/AltTagCheck.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Checks/Content/AltTagCheck.php b/src/Checks/Content/AltTagCheck.php index d5248a2..57671dd 100644 --- a/src/Checks/Content/AltTagCheck.php +++ b/src/Checks/Content/AltTagCheck.php @@ -100,7 +100,14 @@ private function getImageDimensions(string $src, Crawler $node): array ]; } - $dimensions = getimagesize($src); + $dimensions = @getimagesize($src); + + if ($dimensions === false) { + return [ + 'width' => 0, + 'height' => 0, + ]; + } return [ 'width' => $dimensions[0],