本文整理汇总了PHP中League\Flysystem\Filesystem::getThumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::getThumbnail方法的具体用法?PHP Filesystem::getThumbnail怎么用?PHP Filesystem::getThumbnail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类League\Flysystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::getThumbnail方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThumbnailResponse
protected function getThumbnailResponse($path, Filesystem $fs, $size, $cachename)
{
$fileextensionswiththumbnails = $this->container->getParameter('fileextensionswiththumbnails');
$pathexpl = explode('.', $path);
$fileextension = strtolower($pathexpl[count($pathexpl) - 1]);
$ctime = new \DateTime();
if ($size == 'xxs' || !in_array($fileextension, $fileextensionswiththumbnails)) {
$imgdata = $this->getIcon($path, $size);
} else {
$timestamp = $fs->getTimestamp($path);
$fromcache = $this->getImageFromCache($cachename, $timestamp);
if ($fromcache) {
//ist bereits im cache:
$thumbnaildata = $fromcache;
$ctime = new \DateTime();
$ctime->setTimestamp(intval($thumbnaildata[0]));
$imgdata = $thumbnaildata[1];
} else {
$imgdata = $fs->getThumbnail($path, $size);
if ($imgdata) {
$this->memcached->set($cachename, serialize($ctime->getTimestamp() . '|' . $imgdata));
} else {
//icon ausgeben:
$imgdata = $this->getIcon($path, $size);
}
}
}
$expires = 1 * 24 * 60 * 60;
$response = new Response($imgdata);
$response->headers->set('Content-Length', strlen($imgdata));
$response->headers->set('Pragma', 'public');
$response->headers->set('Last-Modified', $ctime->format('D, d M Y H:i:s') . ' GMT');
$response->headers->set('Cache-Control', 'maxage=' . $expires);
$response->headers->set('Content-Type', 'image/png; charset=UTF-8');
$response->headers->set('Expires', gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
return $response;
}