F
Filament12mo ago
danzzz

Display an image (ImageColumn) from local storage (not public accessible)

hey all. I store some images on the local disk which is not accessible by the webserver, its just a file storage. Is it possible to show the images with ImageColumn in a table? Should I make a custom column and use laravel intevention plugin?
Solution:
I ended up with this solution: Forms\Components\ViewField::make('image') ->view('filament.tables.columns.custom-upload-preview'), ...
Jump to solution
1 Reply
Solution
danzzz
danzzz12mo ago
I ended up with this solution: Forms\Components\ViewField::make('image') ->view('filament.tables.columns.custom-upload-preview'), @php use Intervention\Image\ImageManager; use Intervention\Image\Drivers\Gd\Driver; $manager = new ImageManager(new Driver()); $image = $manager->read(storage_path('app/').$getRecord()->file_name); // app/uploads/some.png $image->scaleDown(200); $base64 = base64_encode($image->encode()); @endphp <img class="rounded-xl" src="{{ 'data:image/jpeg;base64,' . $base64 }}" alt="{{ $getRecord()->title }}">
Want results from more Discord servers?
Add your server