public function view(Request $request, Response $response, array $args) { $item = new Item($args['id'], $this->user); $template = new \App\Template('view.twig'); $template->item = $item; $template->title = $item->getTitle(); $template->tags = $item->getTags(); $template->mime_type = $item->getMimeType(); $template->itemReadGroup = $item->getReadGroup(); $template->itemEditGroup = $item->getEditGroup(); // Return the template. $response->setContent($template->render()); return $response; }
/** * @testdox Image thumbnails are correctly resized. * @test */ public function correctSizedThumbnails() { // Create a large image. $img = Image::canvas(1000, 400, '#ccc'); $tmpFilename = $this->dataDir() . '/test-image.jpg'; $img->save($tmpFilename); // Add it to an Item. $item = new Item(null, $this->testUser); $item->save(null, null, $tmpFilename); // Check that the various sizes returned are correct. $this->assertEquals('image/jpeg', $item->getMimeType()); $this->assertFileEquals($tmpFilename, $item->getCachePath('o')); // Load the 'display' size. $display = Image::make($item->getCachePath('d')); $this->assertEquals(700, $display->getWidth()); $this->assertEquals(280, $display->getHeight()); // The thumbnail is always 200 x 200. $thumb = Image::make($item->getCachePath('t')); $this->assertEquals(200, $thumb->getWidth()); $this->assertEquals(200, $thumb->getHeight()); }