From 618f92b3fb6cde750e3fafd114c3f2f1179e434d Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sun, 11 Mar 2012 20:00:50 +0100 Subject: [PATCH] fix thumbnail generation --- apps/gallery/lib/photo.php | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 463df2b5f4..5e6df8069b 100644 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -13,11 +13,11 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. -* +* * You should have received a copy of the GNU Lesser General Public -* License along with this library. If not, see . +* License along with this library. If not, see . * */ @@ -46,39 +46,39 @@ class OC_Gallery_Photo { return $stmt->execute(array($owner, $album_name)); } - public static function removeByPath($path) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path LIKE ?'); - $stmt->execute(array($path)); - } + public static function removeByPath($path) { + $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path LIKE ?'); + $stmt->execute(array($path)); + } - public static function removeById($id) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE photo_id = ?'); - $stmt->execute(array($id)); - } + public static function removeById($id) { + $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE photo_id = ?'); + $stmt->execute(array($id)); + } - public static function removeByAlbumId($albumid) { - $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE album_id = ?'); - $stmt->execute(array($albumid)); - } + public static function removeByAlbumId($albumid) { + $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE album_id = ?'); + $stmt->execute(array($albumid)); + } - public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath) { - $stmt = OC_DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?"); - $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath)); - } + public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath) { + $stmt = OC_DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?"); + $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath)); + } public static function getThumbnail($image_name) { $save_dir = OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/'; $save_dir .= dirname($image_name). '/'; - $image_path = self::getGalleryRoot().$image_name; - $thumb_file = $save_dir . basename($image_name); + $image_path = $image_name; + $thumb_file = $save_dir . basename($image_name); if (file_exists($thumb_file)) { $image = new OC_Image($thumb_file); } else { - $imagePath = OC_Filesystem::getLocalFile($image_path); - if(!file_exists($imagePath)) { + $image_path = OC_Filesystem::getLocalFile($image_path); + if(!file_exists($image_path)) { return null; } - $image = new OC_Image($imagePath); + $image = new OC_Image($image_path); if ($image->valid()) { $image->centerCrop(); $image->resize(200); @@ -95,7 +95,7 @@ class OC_Gallery_Photo { return null; } - public static function getGalleryRoot() { - return OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', ''); - } + public static function getGalleryRoot() { + return OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', ''); + } }