2019-09-26 07:30:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Transformer\Api\Mastodon\v1;
|
|
|
|
|
|
|
|
use App\Media;
|
|
|
|
use League\Fractal;
|
|
|
|
|
|
|
|
class MediaTransformer extends Fractal\TransformerAbstract
|
|
|
|
{
|
|
|
|
public function transform(Media $media)
|
|
|
|
{
|
2021-01-20 02:39:04 +00:00
|
|
|
$res = [
|
2019-09-26 07:30:15 +00:00
|
|
|
'id' => (string) $media->id,
|
|
|
|
'type' => lcfirst($media->activityVerb()),
|
|
|
|
'url' => $media->url(),
|
|
|
|
'preview_url' => $media->thumbnailUrl(),
|
2022-01-03 06:26:18 +00:00
|
|
|
'remote_url' => $media->remote_url,
|
|
|
|
'text_url' => $media->url(),
|
2021-01-20 02:39:04 +00:00
|
|
|
'description' => $media->caption,
|
2021-01-31 00:31:07 +00:00
|
|
|
'blurhash' => $media->blurhash ?? 'U4Rfzst8?bt7ogayj[j[~pfQ9Goe%Mj[WBay'
|
2019-09-26 07:30:15 +00:00
|
|
|
];
|
2021-01-20 02:39:04 +00:00
|
|
|
|
|
|
|
if($media->width && $media->height) {
|
|
|
|
$res['meta'] = [
|
|
|
|
'focus' => [
|
|
|
|
'x' => 0,
|
|
|
|
'y' => 0
|
|
|
|
],
|
|
|
|
'original' => [
|
|
|
|
'width' => $media->width,
|
|
|
|
'height' => $media->height,
|
|
|
|
'size' => "{$media->width}x{$media->height}",
|
|
|
|
'aspect' => $media->width / $media->height
|
|
|
|
]
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
2019-09-26 07:30:15 +00:00
|
|
|
}
|
2022-01-03 06:26:18 +00:00
|
|
|
}
|