/** * Gets a thumbnail of the specified file * * @since API version 1.0 * * @NoAdminRequired * @NoCSRFRequired * * @param int $x * @param int $y * @param string $file URL-encoded filename * @return DataResponse|DataDisplayResponse */ public function getThumbnail($x, $y, $file) { if ($x < 1 || $y < 1) { return new DataResponse(['message' => 'Requested size must be numeric and a positive value.'], Http::STATUS_BAD_REQUEST); } $preview = $this->previewManager->createPreview('files/' . $file, $x, $y, true); if ($preview->valid()) { return new DataDisplayResponse($preview->data(), Http::STATUS_OK, ['Content-Type' => 'image/png']); } else { return new DataResponse(['message' => 'File not found.'], Http::STATUS_NOT_FOUND); } }