awcodes / filament-curator

A media picker plugin for Filament Panels.
MIT License
343 stars 89 forks source link

Fix CuratorColumn image size with px #211

Closed howdu closed 1 year ago

howdu commented 1 year ago

Fixes https://github.com/awcodes/filament-curator/issues/210

Also adds resolution to allow the resized image to be upscaled for HD quality.

CuratorColumn::make()
  ->size(100)
  ->resolution(2);
lotarbo commented 1 year ago

@howdu hi, thank you for your fix, but i think It's now safe, because we can pass string 60em mb just use (int) ?

howdu commented 1 year ago

@lotarbo thanks yeah I thought that too would be cleaner too, but Glide uses only px and it's Filament ImageColumn::getWidth() which adds the 'px' so the reason I went with the str_replace.

Let's see what @awcodes thinks.

lotarbo commented 1 year ago

@howdu i mean we can do this ->width('50em') and ImageColumn::getWidth() return 50em

howdu commented 1 year ago

@howdu i mean we can do this ->width('50em') and ImageColumn::getWidth() return 50em

I think that would be the same issue where Glide wouldn't resize the image because it only accepts px

lotarbo commented 1 year ago

@howdu yeah i know, it creates url article-1.jpg?w=50em&h=50em&fit=crop&fm=webp&s=e6f52076e0f547afebb787baddfcc271 and glide doesn't crop image i only think if we pass int in all situation article-1.jpg?w=50&h=50&fit=crop&fm=webp&s=e6f52076e0f547afebb787baddfcc271 but you right, maybe better do nothing in this)

awcodes commented 1 year ago

Let's go with (int). It's be faster and safer that a preg_replace.

Thanks.

awcodes commented 1 year ago

Awesome. Thanks again.