Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function apply($value, $instance = null, $attribute = null)
'path',
'disk',
'thumbnail',
'large_thumbnail',
'playable_preview_url',
'download_url',
'size',
Expand Down Expand Up @@ -109,6 +110,7 @@ protected function transformUpload(SharpUploadModel $upload): array
'disk' => $upload->disk,
'mime_type' => $upload->mime_type,
'thumbnail' => $this->getThumbnailUrl($upload),
'large_thumbnail' => $this->getLargeThumbnailUrl($upload),
'playable_preview_url' => $this->getPlayableMediaUrl($upload),
'download_url' => URL::temporarySignedRoute(
'code16.sharp.download.show',
Expand All @@ -127,6 +129,25 @@ protected function transformUpload(SharpUploadModel $upload): array
];
}

private function getLargeThumbnailUrl(SharpUploadModel $upload): ?string
{
// prevent generating thumbnail for non-image files
if ($upload->mime_type && ! str($upload->mime_type)->startsWith('image/')) {
return null;
}

return URL::signedRoute(
'code16.sharp.api.form.upload.thumbnail.show',
[
'entityKey' => sharp()->context()->entityKey(),
'instanceId' => sharp()->context()->instanceId(),
'disk' => $upload->disk,
'path' => $upload->file_name,
'width' => 1200,
'height' => 1000,
]);
}

private function getThumbnailUrl(SharpUploadModel $upload): ?string
{
if (! $this->withThumbnails) {
Expand Down
Loading