area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.72k stars 568 forks source link

fix: model not implementing has media should only throw exception if no custom callback is provided #2494

Closed Tofandel closed 6 months ago

Tofandel commented 6 months ago

Description

It's very much possible to implement an Image column with a custom thumbnail (eg coming from youtube or any other service)

Right now the following throws an exception if the Video model doesn't use HasMedias

            Image::make()->field('thumbnail')->title('Thumbnail')
                ->customRender(fn(Video $video) => $video->getThumbnail(80, 80))

But it shouldn't because of the custom render method provided

BTW I noticed a related issue on the browser, using any other field name than thumbnail on image in the browser columns results in the image being displayed as text instead of as an image as well as the order of the columns being wrong