aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBlackEagle <ike.devolder@gmail.com>2012-05-25 22:07:36 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2012-07-11 02:33:10 +0200
commitef1924dbbb662a1e33d7fc74cb7c9e1b36585225 (patch)
treeaa966b69d7039980f4450c9e1240fc259e83f18b
parente7a0c4f0bb73cb6540678e8174c448fdaf5c299d (diff)
downloadnextcloud-server-ef1924dbbb662a1e33d7fc74cb7c9e1b36585225.tar.gz
nextcloud-server-ef1924dbbb662a1e33d7fc74cb7c9e1b36585225.zip
gallery :: display big picture according to exif
- fixes oc-314 - caching of the 'big' images in subfolder view next to the tumbnails - now choosen to use max 1200px for viewing this helps speeding up the viewing process Signed-off-by: BlackEagle <ike.devolder@gmail.com>
-rw-r--r--apps/gallery/ajax/viewImage.php34
-rw-r--r--apps/gallery/js/albums.js2
-rw-r--r--apps/gallery/lib/photo.php31
3 files changed, 66 insertions, 1 deletions
diff --git a/apps/gallery/ajax/viewImage.php b/apps/gallery/ajax/viewImage.php
new file mode 100644
index 00000000000..4f7af1496fc
--- /dev/null
+++ b/apps/gallery/ajax/viewImage.php
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * ownCloud - gallery application
+ *
+ * @author Ike Devolder
+ * @copyright 2012 Ike Devolder
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * 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
+ * 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/>.
+ *
+ */
+
+
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('gallery');
+
+$img = $_GET['img'];
+
+$image = OC_Gallery_Photo::getViewImage($img);
+if ($image) {
+ OCP\Response::enableCaching(3600 * 24); // 24 hour
+ $image->show();
+}
diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js
index 413c71471a3..62d3f783ece 100644
--- a/apps/gallery/js/albums.js
+++ b/apps/gallery/js/albums.js
@@ -79,7 +79,7 @@ Albums={
});
element.append(local);
}
- var photoDisplayTemplate = '<div class="gallery_box"><div class="dummy"></div><div><a rel="images" href="'+OC.linkTo('files','download.php')+'?file=URLPATH"><img src="'+OC.filePath('gallery','ajax','thumbnail.php')+'?img=IMGPATH"></a></div></div>';
+ var photoDisplayTemplate = '<div class="gallery_box"><div class="dummy"></div><div><a rel="images" href="'+OC.linkTo('gallery/ajax','viewImage.php')+'?img=URLPATH"><img src="'+OC.filePath('gallery','ajax','thumbnail.php')+'?img=IMGPATH"></a></div></div>';
for (var i in Albums.photos) {
element.append(photoDisplayTemplate.replace("IMGPATH", escape(Albums.photos[i])).replace("URLPATH", escape(Albums.photos[i])));
}
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
index f9527cb5fdb..38a6690c63b 100644
--- a/apps/gallery/lib/photo.php
+++ b/apps/gallery/lib/photo.php
@@ -97,6 +97,37 @@ class OC_Gallery_Photo {
return null;
}
+ public static function getViewImage($image_name, $owner = null) {
+ if (!$owner) $owner = OCP\USER::getUser();
+ $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/';
+ $save_dir .= dirname($image_name). '/view/';
+ $image_path = $image_name;
+ $view_file = $save_dir . basename($image_name);
+ if (!is_dir($save_dir)) {
+ mkdir($save_dir, 0777, true);
+ }
+ if (file_exists($view_file)) {
+ $image = new OC_Image($view_file);
+ } else {
+ $image_path = OC_Filesystem::getLocalFile($image_path);
+ if(!file_exists($image_path)) {
+ return null;
+ }
+ $image = new OC_Image($image_path);
+ if ($image->valid()) {
+ $image->resize(1200);
+ $image->fixOrientation();
+ $image->save($view_file);
+ }
+ }
+ if ($image->valid()) {
+ return $image;
+ }else{
+ $image->destroy();
+ }
+ return null;
+ }
+
public static function getGalleryRoot() {
return OCP\Config::getUserValue(OCP\USER::getUser(), 'gallery', 'root', '');
}