1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-26 17:56:48 +00:00

Merge pull request #385 from pixelfed/frontend-ui-refactor

Frontend ui refactor
This commit is contained in:
daniel 2018-08-15 18:22:32 -06:00 committed by GitHub
commit 5c3d0d351f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -125,13 +125,15 @@ class Profile extends Model
public function avatar()
{
return $this->hasOne(Avatar::class);
return $this->hasOne(Avatar::class)->withDefault([
'media_path' => 'public/avatars/default.png'
]);
}
public function avatarUrl()
{
$url = Cache::remember("avatar:{$this->id}", 1440, function() {
$path = $this->avatar->media_path ?? 'public/avatars/default.png';
$path = optional($this->avatar)->media_path;
$version = hash('sha1', $this->avatar->created_at);
$path = "{$path}?v={$version}";
return url(Storage::url($path));