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
Did you run
php artisan storage:link
and what errors are you seeing in the console.?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
That shouldn’t be needed. The public disk is the public directory. Maybe your disk config is off.
how can that be off, i followed the instructions
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 brokenSo, 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.
there is no trace of an image tag, only a div with height and width
Is filepath fillable on your model.?
yep
And what is actually saved to that field in the db?
public/images/DSC_0103.JPG
If the disk is setup correctly then you wouldn’t have ‘public’ as part of that path.
storage:link sets that up automatically.
php artisan storage:link --force
and it still didn't work until i added the public part
There’s a config setting off somewhere. What is in config/filesystems.php ‘disks’
Something in your app is overriding the normal / default disks.
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?
Filament doesn’t misconfigure this. It uses Laravel’s storage and filesystem, so if something is off, it’s in the app.
'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
That looks ok. Something is off somewhere though.
Could even be in your nginx config.
using artisan serve , not even apache / nginx
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
APP_URL=http://127.0.0.1:8000
And when you inspect the img src what is the url?
<img src="/storage/images/DSC_0141.JPG" style="
height: 40px;
" class="">
" class="">
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.
simlink in public/storage is /home/bogi/src/ik-photog-take-2/storage/app/public
Try this.
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.
ok, that worked, but now the ImageColumn is broken again
ImageColumn::make('filepath'), works
wow
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.
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
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.