mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
fix: update package names and handle Intervention Image versioning in favicon generation
This commit is contained in:
parent
1ac9c62c6b
commit
4b4197d3ad
3 changed files with 33 additions and 16 deletions
|
|
@ -29,10 +29,10 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"orchestra/testbench": ">=8.0",
|
||||
"nunomaduro/larastan": ">=2.4",
|
||||
"larastan/larastan": ">=2.4",
|
||||
"pestphp/pest": ">=2.0",
|
||||
"pestphp/pest-plugin-laravel": ">=2.0",
|
||||
"intervention/image": "^2.7"
|
||||
"intervention/image": "^2.0|^3.0"
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
includes:
|
||||
- ./vendor/nunomaduro/larastan/extension.neon
|
||||
- ./vendor/larastan/larastan/extension.neon
|
||||
|
||||
parameters:
|
||||
paths:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace ArchTech\SEO\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;
|
||||
use Intervention\Image\ImageManager;
|
||||
|
||||
class GenerateFaviconsCommand extends Command
|
||||
|
|
@ -38,22 +37,40 @@ class GenerateFaviconsCommand extends Command
|
|||
return self::FAILURE;
|
||||
}
|
||||
|
||||
// GD driver doesn't support .ico, that's why we use ImageMagick.
|
||||
$manager = new ImageManager(ImagickDriver::class);
|
||||
// Check Intervention Image version
|
||||
$isV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface');
|
||||
|
||||
if ($isV3) {
|
||||
// v3.x implementation
|
||||
$manager = new ImageManager(
|
||||
new \Intervention\Image\Drivers\Imagick\Driver()
|
||||
);
|
||||
|
||||
$this->comment('Generating ico...');
|
||||
$image = $manager->read($path);
|
||||
$image->resize(32, 32);
|
||||
$image->save(public_path('favicon.ico'));
|
||||
|
||||
$manager
|
||||
$this->comment('Generating png...');
|
||||
$image = $manager->read($path);
|
||||
$image->resize(32, 32);
|
||||
$image->save(public_path('favicon.png'));
|
||||
} else {
|
||||
// v2.x implementation
|
||||
$manager = new ImageManager(['driver' => 'imagick']); // @phpstan-ignore argument.type
|
||||
|
||||
$this->comment('Generating ico...');
|
||||
$manager // @phpstan-ignore method.notFound
|
||||
->make($path)
|
||||
->resize(32, 32)
|
||||
->save(public_path('favicon.ico'));
|
||||
|
||||
$this->comment('Generating png...');
|
||||
|
||||
$manager
|
||||
$manager // @phpstan-ignore method.notFound
|
||||
->make($path)
|
||||
->resize(32, 32)
|
||||
->save(public_path('favicon.png'));
|
||||
}
|
||||
|
||||
$this->info('All favicons have been generated!');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue