From 782562215c73f4b4900b382b80f523603809515e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jir=CC=8Ci=CC=81=20Svoboda?= Date: Tue, 21 Jun 2016 14:17:10 +0200 Subject: [PATCH] Fixed gallerybehavior on localhost --- GalleryBehavior.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/GalleryBehavior.php b/GalleryBehavior.php index 3345bcf..21090a3 100755 --- a/GalleryBehavior.php +++ b/GalleryBehavior.php @@ -302,11 +302,18 @@ public function getImageFilePath($image_id, $version = self::VERSION_ORIGINAL) { $subDir = $this->getVersionSubDir($version, $image_id); - return implode(DIRECTORY_SEPARATOR, [ + $path = implode(DIRECTORY_SEPARATOR, [ $this->directory, $subDir, $this->getFilePath($image_id, $version) ]); + + if (!is_writable($path)) + { + return $_SERVER['DOCUMENT_ROOT'].$path; + } + + return $path; } /** @@ -761,7 +768,12 @@ private function createFolder($filePath) if (!$path) { - mkdir($dirPath, 0777, true); + $result = @mkdir($dirPath, 0777, true); + + if (!$result) + { + @mkdir($_SERVER['DOCUMENT_ROOT'].$dirPath, 0777, true); + } } }