mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Merge pull request #5186 from pixelfed/staging
Update Media model, fix broken thumbnail/gray thumbnail bug
This commit is contained in:
commit
7ed6d48834
2 changed files with 20 additions and 18 deletions
|
@ -31,7 +31,7 @@
|
|||
- Update DirectMessageController, add timestamps to threads ([b24d2554](https://github.com/pixelfed/pixelfed/commit/b24d2554))
|
||||
- Update DirectMessageController, add carousel entity to threads ([96f24f33](https://github.com/pixelfed/pixelfed/commit/96f24f33))
|
||||
- Update and refactor total local post count logic, cache value and schedule updates twice daily to eliminate the perf issue on larger instances ([4f2b8ed2](https://github.com/pixelfed/pixelfed/commit/4f2b8ed2))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
- Update Media model, fix broken thumbnail/gray thumbnail bug ([e33643c2](https://github.com/pixelfed/pixelfed/commit/e33643c2))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.12.1 (2024-05-07)](https://github.com/pixelfed/pixelfed/compare/v0.12.0...v0.12.1)
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App;
|
||||
|
||||
use App\Util\Media\License;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Util\Media\License;
|
||||
use Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Storage;
|
||||
|
||||
class Media extends Model
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ class Media extends Model
|
|||
|
||||
protected $casts = [
|
||||
'srcset' => 'array',
|
||||
'deleted_at' => 'datetime'
|
||||
'deleted_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function status()
|
||||
|
@ -36,12 +36,12 @@ class Media extends Model
|
|||
|
||||
public function url()
|
||||
{
|
||||
if($this->cdn_url) {
|
||||
if ($this->cdn_url) {
|
||||
// return Storage::disk(config('filesystems.cloud'))->url($this->media_path);
|
||||
return $this->cdn_url;
|
||||
}
|
||||
|
||||
if($this->remote_media && $this->remote_url) {
|
||||
if ($this->remote_media && $this->remote_url) {
|
||||
return $this->remote_url;
|
||||
}
|
||||
|
||||
|
@ -50,19 +50,19 @@ class Media extends Model
|
|||
|
||||
public function thumbnailUrl()
|
||||
{
|
||||
if($this->thumbnail_url) {
|
||||
if ($this->thumbnail_url) {
|
||||
return $this->thumbnail_url;
|
||||
}
|
||||
|
||||
if(!$this->remote_media && $this->thumbnail_path) {
|
||||
if (! $this->remote_media && $this->thumbnail_path) {
|
||||
return url(Storage::url($this->thumbnail_path));
|
||||
}
|
||||
|
||||
if($this->remote_media && !$this->thumbnail_path && $this->cdn_url) {
|
||||
if (! $this->thumbnail_path && $this->cdn_url) {
|
||||
return $this->cdn_url;
|
||||
}
|
||||
|
||||
if($this->media_path && $this->mime && in_array($this->mime, ['image/jpeg', 'image/png'])) {
|
||||
if ($this->media_path && $this->mime && in_array($this->mime, ['image/jpeg', 'image/png'])) {
|
||||
return $this->remote_media || Str::startsWith($this->media_path, 'http') ?
|
||||
$this->media_path :
|
||||
url(Storage::url($this->media_path));
|
||||
|
@ -78,9 +78,10 @@ class Media extends Model
|
|||
|
||||
public function mimeType()
|
||||
{
|
||||
if(!$this->mime) {
|
||||
if (! $this->mime) {
|
||||
return;
|
||||
}
|
||||
|
||||
return explode('/', $this->mime)[0];
|
||||
}
|
||||
|
||||
|
@ -91,7 +92,7 @@ class Media extends Model
|
|||
case 'audio':
|
||||
$verb = 'Audio';
|
||||
break;
|
||||
|
||||
|
||||
case 'image':
|
||||
$verb = 'Image';
|
||||
break;
|
||||
|
@ -99,11 +100,12 @@ class Media extends Model
|
|||
case 'video':
|
||||
$verb = 'Video';
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$verb = 'Document';
|
||||
break;
|
||||
}
|
||||
|
||||
return $verb;
|
||||
}
|
||||
|
||||
|
@ -114,11 +116,11 @@ class Media extends Model
|
|||
|
||||
public function getModel()
|
||||
{
|
||||
if(empty($this->metadata)) {
|
||||
if (empty($this->metadata)) {
|
||||
return false;
|
||||
}
|
||||
$meta = $this->getMetadata();
|
||||
if($meta && isset($meta['Model'])) {
|
||||
if ($meta && isset($meta['Model'])) {
|
||||
return $meta['Model'];
|
||||
}
|
||||
}
|
||||
|
@ -127,11 +129,11 @@ class Media extends Model
|
|||
{
|
||||
$license = $this->license;
|
||||
|
||||
if(!$license || strlen($license) > 2 || $license == 1) {
|
||||
if (! $license || strlen($license) > 2 || $license == 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!in_array($license, License::keys())) {
|
||||
if (! in_array($license, License::keys())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -140,7 +142,7 @@ class Media extends Model
|
|||
return [
|
||||
'id' => $res['id'],
|
||||
'title' => $res['title'],
|
||||
'url' => $res['url']
|
||||
'url' => $res['url'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue