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>
This commit is contained in:
BlackEagle 2012-05-25 22:07:36 +02:00 committed by Jörn Friedrich Dreyer
parent e7a0c4f0bb
commit ef1924dbbb
3 changed files with 66 additions and 1 deletions

View file

@ -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();
}

View file

@ -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])));
}

View file

@ -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', '');
}