awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
324 stars 86 forks source link

CurationPreset depend on screen size #317

Closed lacehate closed 12 months ago

lacehate commented 1 year ago

Filament Version

v2.0

Plugin Version

v2.2

PHP Version

PHP 8.0.2

Problem description

CurationPreset depend on screen size, if preset width or height is bigger than window size, choosing preset sets width and height closest values to the preset, i attached code and screenshots, I hope I was able to convey my thought to you, please ask questions
/:

 Curator::navigationGroup('Контент')
            ->navigationSort(2)
            ->resourceLabel('Файловый менеджер')
            ->pluralResourceLabel('Файловый менеджер')
            ->mediaModel(Media::class)
            ->acceptedFileTypes(['image/*'])
            ->disableResourceRegistration();

        $this->app->bind(MediaResource::class, fn() => new CustomMediaResource());
        $this->app->bind(MediaResource\EditMedia::class, fn() => new CustomEditMedia());
        $this->app->bind(MediaResource\CreateMedia::class, fn() => new CustomCreateMedia());
        $this->app->bind(MediaResource\ListMedia::class, fn() => new CustomListMedia());

        Curator::curationPresets([
            CurationPreset::make('lead_img')
                ->label('lead img')
                ->width(1550)
                ->height(707),
            CurationPreset::make('lead_img_mobile')
                ->label('lead img mobile')
                ->width(351)
                ->height(480),
        ]);

Screenshot 2023-10-04 at 15 35 14 Screenshot 2023-10-04 at 15 39 56 Screenshot 2023-10-04 at 15 40 24

Expected behavior

i expect it to correctly display image and crop it using presets

Steps to reproduce

create CurationPreset, set width and height of preset bigger than your crop window, where u select created presets, download high resolution image and try to crop it using ur preset

Reproduction repository

No response

Relevant log output

No response

awcodes commented 12 months ago

I'll do some digging and get back to you. This could even be a bug in cropper.js, but can't say for sure at the moment.

lacehate commented 12 months ago

I'll do some digging and get back to you. This could even be a bug in cropper.js, but can't say for sure at the moment.

Thank you for your answer!

awcodes commented 12 months ago

Ok. I'm not seeing anything on the Curator side that would keep this from working like you want it to.

I am seeing a lot of mention through out cropperjs docs talking about things being bound to the container size itself which leads me to believe that this is a either a bug in cropperjs or an unimplemented feature.

So, I do not have a way to fix this at this time. I am more than open to PRs if you can find a fix for it. Sorry.