F
Filament12mo ago
bogi99

ImageColumn

and FileUpload , so i upload the file ( image ) FileUpload::make('filepath')->disk('local')->directory('images')->visibility('public')->preserveFilenames()->image(), it finishes the upload, i see the picture with the green hue, but when i go to edit the record, i just get the gray rectangle , no picture view, i tried the .env tricks , nothing. same situation with the table display, ImageColumn::make('filepath')->width(60)->height(60), no image is being shown. the files are uploaded for sure, me seeing them again, not happening .. please help
29 Replies
awcodes
awcodes12mo ago
Did you run php artisan storage:link and what errors are you seeing in the console.?
bogi99
bogi99OP12mo ago
yes, i did , many times with --force one of the problems is solved , i needed to add FileUpload::make('filepath')->disk('local')->directory('public/images')->visibility('public')->preserveFilenames()->image(), 'public/images' to the directory and now the edit shows the picture ... put the list view is still broken
awcodes
awcodes12mo ago
That shouldn’t be needed. The public disk is the public directory. Maybe your disk config is off.
bogi99
bogi99OP12mo ago
how can that be off, i followed the instructions
DrByte
DrByte12mo ago
I think he meant something wrong with your Laravel config. Filament's just doing what you tell it to do.
the list view is still broken
So, if you go to the image cell in your table, and inspect it, what's the HTML that's trying to render the image? Does it have a valid image path for the img src ? You could also look at the browser's network inspection tab or the sources inspection tab, and see what image file assets are throwing errors when trying to load, and then look at exactly what it's trying to load. You'll probably find that there's a wrong path being specified. And then you can fix that.
bogi99
bogi99OP12mo ago
there is no trace of an image tag, only a div with height and width
awcodes
awcodes12mo ago
Is filepath fillable on your model.?
bogi99
bogi99OP12mo ago
yep
awcodes
awcodes12mo ago
And what is actually saved to that field in the db?
bogi99
bogi99OP12mo ago
public/images/DSC_0103.JPG
awcodes
awcodes12mo ago
If the disk is setup correctly then you wouldn’t have ‘public’ as part of that path. storage:link sets that up automatically.
bogi99
bogi99OP12mo ago
php artisan storage:link --force and it still didn't work until i added the public part
awcodes
awcodes12mo ago
There’s a config setting off somewhere. What is in config/filesystems.php ‘disks’ Something in your app is overriding the normal / default disks.
bogi99
bogi99OP12mo ago
ImageColumn::make('filepath')->disk('local')->visibility('public'), added visibility public and now the list shows up is this normal, for the filament to absolutely misconfigure itself by default?
awcodes
awcodes12mo ago
Filament doesn’t misconfigure this. It uses Laravel’s storage and filesystem, so if something is off, it’s in the app.
bogi99
bogi99OP12mo ago
'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', 'throw' => false, ], this is my config/filesystems.php section unchanged from install
awcodes
awcodes12mo ago
That looks ok. Something is off somewhere though. Could even be in your nginx config.
bogi99
bogi99OP12mo ago
using artisan serve , not even apache / nginx
awcodes
awcodes12mo ago
Well that will create issues. Serve runs on a specific port and ip while the storage facade will return it as localhost creating mismatch. What is the actual app_url set to in your .env
bogi99
bogi99OP12mo ago
awcodes
awcodes12mo ago
And when you inspect the img src what is the url?
bogi99
bogi99OP12mo ago
<img src="/storage/images/DSC_0141.JPG" style=" height: 40px;
" class="">
awcodes
awcodes12mo ago
And I highly recommend not using serve when dealing with assets. Valet, homestead or heard would keep this from happening. Yea, something is happening with your storage link. Seems like it’s not getting symlinked properly. If it’s working for you great, but I think you might have problems with this going to production.
bogi99
bogi99OP12mo ago
simlink in public/storage is /home/bogi/src/ik-photog-take-2/storage/app/public
awcodes
awcodes12mo ago
Try this.
FileUpload::make('filepath')->directory('images')->preserveFilenames()->image()
FileUpload::make('filepath')->directory('images')->preserveFilenames()->image()
Will have to upload the image again though. The disk shouldn’t need to set to local and it defaults to public. You might be trying to override things that don’t need to be overridden.
bogi99
bogi99OP12mo ago
ok, that worked, but now the ImageColumn is broken again ImageColumn::make('filepath'), works wow
awcodes
awcodes12mo ago
There you go. Sorry for all the back and forth, just now realized what was happening when you were setting the disk to ‘local’ Hard to read code on a phone with no syntax highlighting. Lol.
bogi99
bogi99OP12mo ago
the back and forth is fine, i wanted to get to the bottom of it. i wanted to set the disk to local , as a i wanted it there, but i guess that messed things up
awcodes
awcodes12mo ago
Images need a url that can be accessed publicly, unless it’s strictly for download. That’s where the visibility option comes in into play. If the visibility is private then it will append a token to the url so the image can only be accessed with the token.
Want results from more Discord servers?
Add your server