Log wrong requests
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
bebeb8a817
commit
1f87dd9f5e
29
Plugin.php
29
Plugin.php
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Aweos\Resizer;
|
||||
|
||||
use Log;
|
||||
use Aweos\Resizer\Classes\CacheManager;
|
||||
use Aweos\Resizer\Classes\FileObserver;
|
||||
use Aweos\Resizer\Classes\ImageResizer;
|
||||
|
@ -54,9 +55,9 @@ class Plugin extends PluginBase
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
app()->bind(ImageResizer::class, function() {
|
||||
app()->bind(ImageResizer::class, function () {
|
||||
$disk = (new File())->getDisk();
|
||||
$dir = (new File(['is_public' => true]))->getStorageDirectory().'c/';
|
||||
$dir = (new File(['is_public' => true]))->getStorageDirectory() . 'c/';
|
||||
$media = MediaLibrary::instance();
|
||||
|
||||
return new ImageResizer($disk, $dir, $media);
|
||||
|
@ -64,27 +65,28 @@ class Plugin extends PluginBase
|
|||
|
||||
app()->bind('resize', fn () => app(CacheManager::class));
|
||||
|
||||
Event::listen('media.file.upload', function($widget, $filePath, $uploadedFile) {
|
||||
Event::listen('media.file.upload', function ($widget, $filePath, $uploadedFile) {
|
||||
if ((new MediaPath($filePath))->shouldProcess()) {
|
||||
Queue::push(ResizeJob::class, [$filePath], Setting::get('queue'));
|
||||
}
|
||||
});
|
||||
Event::listen('media.file.delete', function($widget, $filePath) {
|
||||
Event::listen('media.file.delete', function ($widget, $filePath) {
|
||||
app(FileObserver::class)->delete(new MediaPath($filePath));
|
||||
app(CacheManager::class)->delete(new MediaPath($filePath));
|
||||
});
|
||||
|
||||
Event::listen('media.file.move', function($widget, $old, $new) {
|
||||
Event::listen('media.file.move', function ($widget, $old, $new) {
|
||||
app(FileObserver::class)->rename(new MediaPath($old), new MediaPath($new));
|
||||
app(CacheManager::class)->delete(new MediaPath($old));
|
||||
});
|
||||
Event::listen('media.file.rename', function($widget, $old, $new) {
|
||||
Event::listen('media.file.rename', function ($widget, $old, $new) {
|
||||
app(FileObserver::class)->rename(new MediaPath($old), new MediaPath($new));
|
||||
app(CacheManager::class)->delete(new MediaPath($old));
|
||||
});
|
||||
}
|
||||
|
||||
public function registerSettings() {
|
||||
public function registerSettings()
|
||||
{
|
||||
return [
|
||||
'resizer' => [
|
||||
'label' => 'Resizer Settings',
|
||||
|
@ -99,17 +101,22 @@ class Plugin extends PluginBase
|
|||
];
|
||||
}
|
||||
|
||||
public function registerMarkupTags() {
|
||||
public function registerMarkupTags()
|
||||
{
|
||||
return [
|
||||
'filters' => [
|
||||
'resize' => fn ($media, $size = 'original', $sizes = null, $options = []) => app(CacheManager::class)->get(
|
||||
'resize' => function ($media, $size = 'original', $sizes = null, $options = []) {
|
||||
if (is_null($media)) {
|
||||
Log::warning('Media not found in path ' . url()->current());
|
||||
}
|
||||
return app(CacheManager::class)->get(
|
||||
new MediaPath($media),
|
||||
$size,
|
||||
$sizes,
|
||||
$options,
|
||||
)
|
||||
);
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue