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; }