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": {
|
"require-dev": {
|
||||||
"orchestra/testbench": ">=8.0",
|
"orchestra/testbench": ">=8.0",
|
||||||
"nunomaduro/larastan": ">=2.4",
|
"larastan/larastan": ">=2.4",
|
||||||
"pestphp/pest": ">=2.0",
|
"pestphp/pest": ">=2.0",
|
||||||
"pestphp/pest-plugin-laravel": ">=2.0",
|
"pestphp/pest-plugin-laravel": ">=2.0",
|
||||||
"intervention/image": "^2.7"
|
"intervention/image": "^2.0|^3.0"
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
includes:
|
includes:
|
||||||
- ./vendor/nunomaduro/larastan/extension.neon
|
- ./vendor/larastan/larastan/extension.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
paths:
|
paths:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||||
namespace ArchTech\SEO\Commands;
|
namespace ArchTech\SEO\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;
|
|
||||||
use Intervention\Image\ImageManager;
|
use Intervention\Image\ImageManager;
|
||||||
|
|
||||||
class GenerateFaviconsCommand extends Command
|
class GenerateFaviconsCommand extends Command
|
||||||
|
|
@ -38,22 +37,40 @@ class GenerateFaviconsCommand extends Command
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GD driver doesn't support .ico, that's why we use ImageMagick.
|
// Check Intervention Image version
|
||||||
$manager = new ImageManager(ImagickDriver::class);
|
$isV3 = interface_exists('\Intervention\Image\Interfaces\DriverInterface');
|
||||||
|
|
||||||
$this->comment('Generating ico...');
|
if ($isV3) {
|
||||||
|
// v3.x implementation
|
||||||
|
$manager = new ImageManager(
|
||||||
|
new \Intervention\Image\Drivers\Imagick\Driver()
|
||||||
|
);
|
||||||
|
|
||||||
$manager
|
$this->comment('Generating ico...');
|
||||||
->make($path)
|
$image = $manager->read($path);
|
||||||
->resize(32, 32)
|
$image->resize(32, 32);
|
||||||
->save(public_path('favicon.ico'));
|
$image->save(public_path('favicon.ico'));
|
||||||
|
|
||||||
$this->comment('Generating png...');
|
$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
|
||||||
|
|
||||||
$manager
|
$this->comment('Generating ico...');
|
||||||
->make($path)
|
$manager // @phpstan-ignore method.notFound
|
||||||
->resize(32, 32)
|
->make($path)
|
||||||
->save(public_path('favicon.png'));
|
->resize(32, 32)
|
||||||
|
->save(public_path('favicon.ico'));
|
||||||
|
|
||||||
|
$this->comment('Generating png...');
|
||||||
|
$manager // @phpstan-ignore method.notFound
|
||||||
|
->make($path)
|
||||||
|
->resize(32, 32)
|
||||||
|
->save(public_path('favicon.png'));
|
||||||
|
}
|
||||||
|
|
||||||
$this->info('All favicons have been generated!');
|
$this->info('All favicons have been generated!');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue