本文整理匯總了PHP中app\Item::getCachePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::getCachePath方法的具體用法?PHP Item::getCachePath怎麽用?PHP Item::getCachePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Item
的用法示例。
在下文中一共展示了Item::getCachePath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
public function render(Request $request, Response $response, array $args)
{
$item = new Item($args['id']);
$size = isset($args['size']) ? $args['size'] : 'o';
$version = isset($args['version']) ? $args['version'] : null;
$cacheFile = $item->getCachePath($size, $version);
$fileResponse = new BinaryFileResponse($cacheFile);
$fileResponse->headers->set('Content-Type', 'image/png');
$fileResponse->setFile($cacheFile);
$fileResponse->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $item->getTitle() . '.png');
return $fileResponse;
}
示例2: correctSizedThumbnails
/**
* @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());
}