@afoysal if you don't want to use the fallback you can set your image as such:
$image = Gravatar::exists('[email protected]') ? Gravatar::get('[email protected]') : url('images/user.jpg');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using this ( https://github.com/creativeorange) package. My controller code is like below.
$data['gravatar'] = (!empty(auth()->user()->email)) ? Gravatar::fallback(url('images/user.jpg'))->get(auth()->user()->email) : null;
dd($data['gravatar']);
I am getting output like below
"https://secure.gravatar.com/avatar/a516098e1de8e2756fa4bf045c7a4cb2.jpg?s=150&d=http%3A%2F%2F127.0.0.1%3A8000%2Fimages%2Fuser.jpg&r=g"
But I would like to get output like below
http://127.0.0.1:8000/images/user.jpg
@afoysal if you use the fallback method you won't be able to display images served from your development environment until they are publicly available.
gravatar grabs your public image and then serves it from its own https domain rather that defaulting to the path you gave it.
if you use the code I posted in my first comment then you should be able to use your local image if the remote gravatar doesn't exist and that will provide images for you as you develop your project.
Please or to participate in this conversation.