garrettmassey's avatar

Nova is trying to display an image as the user's avatar / gravatar, despite not defining one

In our app, users can upload a signature image that they can use to automatically insert into emails sent by the system, just as a nice personalization detail. Most users will not have a signature image. In Nova, I have noticed that if my authenticated user has a signature image, Nova tries to make that signature image the profile image / avatar for my user, despite me not defining an Avatar field anywhere in the user resource. I want to be able to disable this behavior, but I can't figure out what is causing it.

Here is how the image field is set up on the update page and the detail page respectively:

//in fieldsForUpdate() method
Image::make(
                                name: 'Signature',
                                attribute: 'signature'
                            )->disk('internal')
                                ->storeAs(function (NovaRequest $request) {
                                    return $this->resource->uuid . '.' . $request->signature->getClientOriginalExtension();
                                })->required()
                                ->size('w-full')
                                ->stacked()
                                ->help('Please upload a digital image of your signature. You can sign a blank document in Adobe Acrobat or MacOS Preview, and screenshot the signature from there. This is only required for staff who interact with signed email notifications.')
                                ->disableDownload(),
//in fieldsForDetail() method
Image::make(
                                name: 'Signature',
                                attribute: 'signature'
                            )->disableDownload()
                                ->disk('internal')
                                ->size('w-full')
                                ->preview(function ($value, $disk) {
                                    return $value
                                        ? route('user.signature', ['filename' => $value])
                                        : null;
                                })
                                ->maxWidth(200)
                                ->stacked()
                                ->canSee(fn () => $request->user()->id === Auth::id() || Auth::user()->isSysadmin()),

So if I delete the image, save my profile, the avatar icon goes away in the user menu, but if I upload any image to the signature, Nova tries to make it my avatar.

The signature images are stored in a specific disk not in public storage, and there is a special controller that restricts access so that only the authenticated user can access their specific signature image (that and the system admin).

What might be causing this and how can I disable it?

0 likes
1 reply
garrettmassey's avatar
Level 6

Adding the following to each of the Image fields prevents the thumbnail from being displayed on the user-menu:

->thumbnail(fn() => null)

Please or to participate in this conversation.