-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use absolute URLs as images #25
Comments
How I always implement avatar for user is like blow:
So I am happy if @jameslkingsley is mentioned where implemented. |
You can easily customize the thumbnail url generation, this is how I display my team logos because the
I also can display the Facebook user photos in the index only using this code
Hope it's help |
I am using Spark, which has an absolute Spark users need to stick with absolute urls unless they want to fix all of the places in Spark that those are expected – so I opt'd for overriding the setter to have Nova play ball and store an absolute url to the public disk address – and then a custom thumbnail callback to stop Nova url'ing the value in its own renders. // nova
public function fields(Request $request)
{
return [
Avatar::make(str_repeat(' ', 8), 'photo_url')
->disk('public')
->thumbnail(function () {
return $this->photo_url;
}),
]
} // models
public function setPhotoUrlAttribute($value)
{
if ($value && !\Illuminate\Support\Str::startsWith($value, 'http')) {
$value = \Storage::disk('public')->url($value);
}
$this->attributes['photo_url'] = $value;
} |
This should be fixed in 1.0.18 |
For anyone else who may have had this problem... I didn't realize there was a |
This was a great solution, however |
@AdrianwithaW you're looking for |
a workaround to display images from the public folder or from absolute URLs
|
if your filed avatar starts with http://
|
was this fixed? cause i'm still cannot show the avatar with full url |
@FB-LilianaIturribarria No there is still not fix for this. This should be something stupid simple like |
Version: 1.0.5
There are cases where the image in your database is just a full URL, especially when using seeded data (lorempixel.com). Currently the
Image
andAvatar
fields don't seem to support this - should be an easy fix to check if the value starts withhttp
and if so just return with that instead.The text was updated successfully, but these errors were encountered: