/** * Returns the smallest thumbnail for a file. * * @param $filename * * @return string Thumbnail Name */ public function getThumbnailFilename($filename) { // legacy fallback for older calls. if (preg_match('/\\.thumb$/', $filename)) { return $filename; } if (!file_exists($filename) && !file_exists($this->cx->getWebsitePath() . '/' . ltrim($filename, '/'))) { return $filename . '.thumb'; } $webpath = pathinfo($filename, PATHINFO_DIRNAME); if (!file_exists($filename)) { $filename = $this->cx->getWebsitePath() . $filename; } if (file_exists($filename) && MediaSourceManager::isSubdirectory($this->cx->getWebsitePath(), $filename)) { $this->createThumbnailFromPath($filename); } $extension = pathinfo($filename, PATHINFO_EXTENSION); $filename = pathinfo($filename, PATHINFO_FILENAME); $this->getThumbnails(); $thumbnailType = $this->thumbnails[0]; $thumbnail = preg_replace('/\\.' . lcfirst($extension) . '$/', $thumbnailType['value'] . '.' . lcfirst($extension), $webpath . '/' . $filename . '.' . $extension); return $thumbnail; }