OC\Preview - proper handling of a cached previews's filename
This commit is contained in:
parent
33ac4d93d6
commit
21abebf96a
|
@ -283,6 +283,10 @@ class Preview {
|
||||||
$fileinfo = $this->fileview->getFileInfo($file);
|
$fileinfo = $this->fileview->getFileInfo($file);
|
||||||
$fileid = $fileinfo['fileid'];
|
$fileid = $fileinfo['fileid'];
|
||||||
|
|
||||||
|
if(is_null($fileid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/';
|
$previewpath = $this->getThumbnailsFolder() . '/' . $fileid . '/';
|
||||||
if(!$this->userview->is_dir($previewpath)) {
|
if(!$this->userview->is_dir($previewpath)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -293,18 +297,19 @@ class Preview {
|
||||||
return $previewpath . $maxX . '-' . $maxY . '.png';
|
return $previewpath . $maxX . '-' . $maxY . '.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
$wantedaspectratio = $maxX / $maxY;
|
$wantedaspectratio = (float) ($maxX / $maxY);
|
||||||
|
|
||||||
//array for usable cached thumbnails
|
//array for usable cached thumbnails
|
||||||
$possiblethumbnails = array();
|
$possiblethumbnails = array();
|
||||||
|
|
||||||
$allthumbnails = $this->userview->getDirectoryContent($previewpath);
|
$allthumbnails = $this->userview->getDirectoryContent($previewpath);
|
||||||
foreach($allthumbnails as $thumbnail) {
|
foreach($allthumbnails as $thumbnail) {
|
||||||
$size = explode('-', $thumbnail['name']);
|
$name = rtrim($thumbnail['name'], '.png');
|
||||||
$x = $size[0];
|
$size = explode('-', $name);
|
||||||
$y = $size[1];
|
$x = (int) $size[0];
|
||||||
|
$y = (int) $size[1];
|
||||||
|
|
||||||
$aspectratio = $x / $y;
|
$aspectratio = (float) ($x / $y);
|
||||||
if($aspectratio !== $wantedaspectratio) {
|
if($aspectratio !== $wantedaspectratio) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue