diff options
author | Georg Ehrke <developer@georgehrke.com> | 2013-07-12 11:50:24 +0200 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2013-07-12 11:50:24 +0200 |
commit | 21abebf96a45323b81ddf057d3851d25085b59ad (patch) | |
tree | 3d502695853383533ce028028018f85f4791a4f8 | |
parent | 33ac4d93d63b98761cf9c09467dcad7bc5d34bf0 (diff) | |
download | nextcloud-server-21abebf96a45323b81ddf057d3851d25085b59ad.tar.gz nextcloud-server-21abebf96a45323b81ddf057d3851d25085b59ad.zip |
OC\Preview - proper handling of a cached previews's filename
-rwxr-xr-x | lib/preview.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/preview.php b/lib/preview.php index 5576981225b..08c0b7e20d0 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -283,6 +283,10 @@ class Preview { $fileinfo = $this->fileview->getFileInfo($file); $fileid = $fileinfo['fileid']; + if(is_null($fileid)) { + return false; + } + $previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/'; if(!$this->userview->is_dir($previewpath)) { return false; @@ -293,18 +297,19 @@ class Preview { return $previewpath . $maxX . '-' . $maxY . '.png'; } - $wantedaspectratio = $maxX / $maxY; + $wantedaspectratio = (float) ($maxX / $maxY); //array for usable cached thumbnails $possiblethumbnails = array(); $allthumbnails = $this->userview->getDirectoryContent($previewpath); foreach($allthumbnails as $thumbnail) { - $size = explode('-', $thumbnail['name']); - $x = $size[0]; - $y = $size[1]; + $name = rtrim($thumbnail['name'], '.png'); + $size = explode('-', $name); + $x = (int) $size[0]; + $y = (int) $size[1]; - $aspectratio = $x / $y; + $aspectratio = (float) ($x / $y); if($aspectratio !== $wantedaspectratio) { continue; } |