1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-26 09:46:49 +00:00
pixelfed/app/Media.php

64 lines
1.1 KiB
PHP
Raw Normal View History

2018-04-16 01:26:48 +00:00
<?php
namespace App;
2018-06-14 00:52:42 +00:00
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
2018-08-28 03:07:36 +00:00
use Storage;
2018-04-16 01:26:48 +00:00
class Media extends Model
{
2018-06-14 00:52:42 +00:00
use SoftDeletes;
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
2018-08-28 03:07:36 +00:00
2018-05-20 02:59:59 +00:00
public function url()
{
2018-08-28 03:07:36 +00:00
$path = $this->media_path;
$url = Storage::url($path);
return url($url);
2018-05-20 02:59:59 +00:00
}
public function thumbnailUrl()
{
2018-08-28 03:07:36 +00:00
$path = $this->thumbnail_path;
$url = Storage::url($path);
return url($url);
}
2018-10-10 01:24:42 +00:00
public function mimeType()
{
return explode('/', $this->mime)[0];
}
public function activityVerb()
{
$verb = 'Image';
switch ($this->mimeType()) {
case 'image':
break;
case 'video':
$verb = 'Video';
break;
default:
$verb = 'Document';
break;
}
return $verb;
}
2018-10-16 18:31:29 +00:00
public function getMetadata()
{
return json_decode($this->metadata, true, 3);
}
2018-04-16 01:26:48 +00:00
}