vormkracht10/laravel-seo-scanner

getimagesize failing on relative path

Closed this issue · 3 comments

Hi guys! Love the package and it is awesome to see other dutchies in the laravel open source space :)

So I am using the package to scan our blog for which we use Statamic.
Statamic outputs the images with the following format:
/assets/listicles/2022/fast-excel.png
So there is no base URL, this is causing the getimagesize to fail in the AltTagCheck class.

Below the error:

 ErrorException 

  getimagesize(/assets/listicles/2022/fast-excel.png): Failed to open stream: No such file or directory

  at vendor/vormkracht10/laravel-seo-scanner/src/Checks/Content/AltTagCheck.php:93
     89▕                 'height' => $node->attr('height'),
     90▕             ];
     91▕         }
     92▕ 
  ➜  93▕         $dimensions = getimagesize($src);
     94▕ 
     95▕         return [
     96▕             'width' => $dimensions[0],
     97▕             'height' => $dimensions[1],

      +36 vendor frames
  37  [internal]:0
      Vormkracht10\Seo\Commands\SeoScan::Vormkracht10\Seo\Commands\{closure}()

      +18 vendor frames
  56  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Is there a way for the package to know to check the base URL + the URL in the image tag.

Would love to know your thoughts on a solution.
Am willing to submit an PR if that is okay with you :)

Baspa commented

@LarsWiegers thanks for mentioning this issue. We have a helper which should add the base url if it's not present. I see that's it not correctly implemented in this check. I will make a PR later today to fix this issue and let you know when it's ready! 😄

Baspa commented

Fixed in #43, version v3.3.1! @LarsWiegers

Thanks @Baspa !