mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 07:45:22 +00:00
Update avatars, use jpeg default
This commit is contained in:
parent
d698b4d1d2
commit
f6528c8470
10 changed files with 31 additions and 10 deletions
|
@ -53,7 +53,11 @@ class AvatarDefaultMigration extends Command
|
|||
|
||||
Avatar::whereChangeCount(0)->chunk(50, function($avatars) use ($bar) {
|
||||
foreach($avatars as $avatar) {
|
||||
if($avatar->media_path == 'public/avatars/default.png' || $avatar->thumb_path == 'public/avatars/default.png') {
|
||||
if( $avatar->media_path == 'public/avatars/default.png' ||
|
||||
$avatar->thumb_path == 'public/avatars/default.png' ||
|
||||
$avatar->media_path == 'public/avatars/default.jpg' ||
|
||||
$avatar->thumb_path == 'public/avatars/default.jpg' ||
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,12 @@ class AvatarController extends Controller
|
|||
|
||||
$avatar = $profile->avatar;
|
||||
|
||||
if($avatar->media_path == 'public/avatars/default.png' || $avatar->thumb_path == 'public/avatars/default.png') {
|
||||
if( $avatar->media_path == 'public/avatars/default.png' ||
|
||||
$avatar->thumb_path == 'public/avatars/default.png' ||
|
||||
$avatar->media_path == 'public/avatars/default.jpg' ||
|
||||
$avatar->thumb_path == 'public/avatars/default.jpg' ||
|
||||
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -132,8 +137,8 @@ class AvatarController extends Controller
|
|||
@unlink(storage_path('app/' . $avatar->thumb_path));
|
||||
}
|
||||
|
||||
$avatar->media_path = 'public/avatars/default.png';
|
||||
$avatar->thumb_path = 'public/avatars/default.png';
|
||||
$avatar->media_path = 'public/avatars/default.jpg';
|
||||
$avatar->thumb_path = 'public/avatars/default.jpg';
|
||||
$avatar->change_count = $avatar->change_count + 1;
|
||||
$avatar->save();
|
||||
|
||||
|
|
|
@ -70,7 +70,10 @@ class AvatarOptimize implements ShouldQueue
|
|||
|
||||
protected function deleteOldAvatar($new, $current)
|
||||
{
|
||||
if (storage_path('app/'.$new) == $current || Str::endsWith($current, 'avatars/default.png')) {
|
||||
if ( storage_path('app/'.$new) == $current ||
|
||||
Str::endsWith($current, 'avatars/default.png') ||
|
||||
Str::endsWith($current, 'avatars/default.jpg'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (is_file($current)) {
|
||||
|
|
|
@ -41,7 +41,7 @@ class CreateAvatar implements ShouldQueue
|
|||
public function handle()
|
||||
{
|
||||
$profile = $this->profile;
|
||||
$path = 'public/avatars/default.png';
|
||||
$path = 'public/avatars/default.jpg';
|
||||
$avatar = new Avatar();
|
||||
$avatar->profile_id = $profile->id;
|
||||
$avatar->media_path = $path;
|
||||
|
|
|
@ -48,11 +48,17 @@ class AvatarObserver
|
|||
public function deleting(Avatar $avatar)
|
||||
{
|
||||
$path = storage_path('app/'.$avatar->media_path);
|
||||
if(is_file($path) && $avatar->media_path != 'public/avatars/default.png') {
|
||||
if( is_file($path) &&
|
||||
$avatar->media_path != 'public/avatars/default.png' &&
|
||||
$avatar->media_path != 'public/avatars/default.jpg'
|
||||
) {
|
||||
@unlink($path);
|
||||
}
|
||||
$path = storage_path('app/'.$avatar->thumb_path);
|
||||
if(is_file($path) && $avatar->thumb_path != 'public/avatars/default.png') {
|
||||
if( is_file($path) &&
|
||||
$avatar->thumb_path != 'public/avatars/default.png' &&
|
||||
$avatar->media_path != 'public/avatars/default.jpg'
|
||||
) {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class Profile extends Model
|
|||
public function avatar()
|
||||
{
|
||||
return $this->hasOne(Avatar::class)->withDefault([
|
||||
'media_path' => 'public/avatars/default.png',
|
||||
'media_path' => 'public/avatars/default.jpg',
|
||||
'change_count' => 0
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -103,6 +103,8 @@ class RestrictedNames
|
|||
'api',
|
||||
'audio',
|
||||
'auth',
|
||||
'avatar',
|
||||
'avatars',
|
||||
'b',
|
||||
'bartender',
|
||||
'broadcast',
|
||||
|
|
3
storage/app/public/avatars/.gitignore
vendored
3
storage/app/public/avatars/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*
|
||||
!.gitignore
|
||||
!default.png
|
||||
!default.png
|
||||
!default.jpg
|
BIN
storage/app/public/avatars/default.jpg
Normal file
BIN
storage/app/public/avatars/default.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 14 KiB |
Loading…
Reference in a new issue