Skip to content

getimagesize failing on relative path #42

Closed
@LarsWiegers

Description

@LarsWiegers

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 :)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions