mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update MediaTransformers, include meta attribute with focus and dimensions
This commit is contained in:
parent
40bd64aae7
commit
f8cbe1e42c
2 changed files with 38 additions and 3 deletions
|
@ -9,7 +9,7 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
|||
{
|
||||
public function transform(Media $media)
|
||||
{
|
||||
return [
|
||||
$res = [
|
||||
'id' => (string) $media->id,
|
||||
'type' => lcfirst($media->activityVerb()),
|
||||
'url' => $media->url(),
|
||||
|
@ -17,7 +17,25 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
|||
'preview_url' => $media->thumbnailUrl(),
|
||||
'text_url' => null,
|
||||
'meta' => null,
|
||||
'description' => $media->caption
|
||||
'description' => $media->caption,
|
||||
'blurhash' => $media->blurhash
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
|||
{
|
||||
public function transform(Media $media)
|
||||
{
|
||||
return [
|
||||
$res = [
|
||||
'id' => (string) $media->id,
|
||||
'type' => $media->activityVerb(),
|
||||
'url' => $media->url() . '?cb=1&_v=' . time(),
|
||||
|
@ -26,5 +26,22 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
|||
'mime' => $media->mime,
|
||||
'blurhash' => $media->blurhash
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue