postService = $postService; $this->fileService = $fileService; $this->httpHelper = $httpHelper; $this->thumbnailService = $thumbnailService; } public function registerRoutes(\Szurubooru\Router $router) { $router->get('/api/posts/:postName/content', [$this, 'getPostContent']); $router->get('/api/posts/:postName/thumbnail/:size', [$this, 'getPostThumbnail']); } public function getPostContent($postName) { $post = $this->postService->getByName($postName); $source = $post->getContentPath(); $this->fileService->serve($source); } public function getPostThumbnail($postName, $size) { $post = $this->postService->getByName($postName); $source = $post->getThumbnailSourceContentPath(); if (!$this->fileService->exists($source)) $source = $post->getContentPath(); $sizedSource = $this->thumbnailService->getOrGenerate($source, $size, $size); $this->fileService->serve($sizedSource); } }