nzmattman's avatar

Image previews with laravel nova

Hi team.

I have an app that uses a different sub domain for nova and a different sub domain for public.

I am having issues with images loading their previews in nova.

An empty image and the blog saying it is not found

however, when I view the resource, I can see the images.

Here is what I have so far;

filesystem

        'guides' => [
            'driver' => 'local',
            'root' => storage_path('app/public/guides'),
            'url' => env('APP_URL').'/storage/guides',
            'visibility' => 'public',
        ],

resource

    public function fields()
    {
        return [
            Image::make('Image')
                ->disk('guides')
                ->disableDownload()
                ->prunable()
                ->thumbnail(function ($value, $disk) {
                    return $value
                        ? str_replace('www', 'admin', Storage::disk($disk)->url($value))
                        : null;
                })
                ->preview(function ($value, $disk) {
                    return $value
                        ? str_replace('www', 'admin', Storage::disk($disk)->url($value))
                        : null;
                })
                ->required(),
            URL::make('Link'),
        ];
    }

for the life of me I can't workout what is happening

any ideas?

0 likes
2 replies
martinbean's avatar

@nzmattman This sounds like something you should be configuring in your disk configuration; not doing string manipulation in your Nova resources, because you’re going to have to do the same manipulation in every resource you want preview images.

nzmattman's avatar

@martinbean It actually doesn't seem to make a difference. The end user view is on the www domain, which is the default domain for the app. Nova is under admin. Doing what I have done there seems to be the only way to actually show the broken thumbnail, anything else shows only the upload field, and a broken red x in the view.

It may actually be an issue with the multi fields plugin we are using. Seems others have had similar issues as to the one I'm seeing here.

Please or to participate in this conversation.