]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix thumbnail generation
authorBartek Przybylski <bart.p.pl@gmail.com>
Sun, 11 Mar 2012 19:00:50 +0000 (20:00 +0100)
committerBartek Przybylski <bart.p.pl@gmail.com>
Sun, 11 Mar 2012 19:00:50 +0000 (20:00 +0100)
apps/gallery/lib/photo.php

index 463df2b5f4b92e0b5c9d991fee1dd1a99eeca423..5e6df8069b50aaa68b89185c6432e5e2abb05a11 100644 (file)
 * 
 * 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 <http://www.gnu.org/licenses/>.
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
 * 
 */
 
@@ -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', '');
+       }
 }