summaryrefslogtreecommitdiffstats
path: root/apps/gallery
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2011-10-27 20:27:57 +0200
committerBartek Przybylski <bart.p.pl@gmail.com>2011-10-27 20:27:57 +0200
commit0d022de0f4d63dcbec252498282240f5b2e43e73 (patch)
tree7e877d41e80633fa5da51702ee51dfda398df5e1 /apps/gallery
parentc32cce4b35919c255089922abe64f5fe833ecb27 (diff)
parent715e376cd2cc6bb2a65be0720c6c1fff0acaa5b9 (diff)
downloadnextcloud-server-0d022de0f4d63dcbec252498282240f5b2e43e73.tar.gz
nextcloud-server-0d022de0f4d63dcbec252498282240f5b2e43e73.zip
Merge branch 'master' into gallery
Diffstat (limited to 'apps/gallery')
-rw-r--r--apps/gallery/ajax/getCovers.php8
-rw-r--r--apps/gallery/ajax/thumbnail.php17
-rw-r--r--apps/gallery/lib_scanner.php4
-rw-r--r--apps/gallery/templates/view_album.php14
4 files changed, 30 insertions, 13 deletions
diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php
index d84bf2a7903..b9c7558a53c 100644
--- a/apps/gallery/ajax/getCovers.php
+++ b/apps/gallery/ajax/getCovers.php
@@ -18,6 +18,7 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $
default:
exit();
}
+ if(!$myImage) exit();
$ratio_orig = $width_orig/$height_orig;
if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
@@ -52,8 +53,11 @@ $targetImg = imagecreatetruecolor($numOfItems*$box_size, $box_size);
$counter = 0;
while (($i = $result->fetchRow()) && $counter < $numOfItems) {
$imagePath = OC::$CONFIG_DATADIRECTORY . $i['file_path'];
- CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size);
- $counter++;
+ if(file_exists($imagePath))
+ {
+ CroppedThumbnail($imagePath, $box_size, $box_size, $targetImg, $counter*$box_size);
+ $counter++;
+ }
}
header('Content-Type: image/png');
diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php
index f24782390f6..a1416452932 100644
--- a/apps/gallery/ajax/thumbnail.php
+++ b/apps/gallery/ajax/thumbnail.php
@@ -5,6 +5,9 @@ OC_JSON::checkAppEnabled('gallery');
function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource.
//getting the image dimensions
+ if(! function_exists('imagecreatefromjpeg'))
+ OC_Log::write('gallery','GD module not installed',OC_Log::ERROR);
+
list($width_orig, $height_orig) = getimagesize($imgSrc);
switch (strtolower(substr($imgSrc, strrpos($imgSrc, '.')+1))) {
case "jpeg":
@@ -18,6 +21,7 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSr
default:
exit();
}
+ if(!$myImage) exit();
$ratio_orig = $width_orig/$height_orig;
if ($thumbnail_width/$thumbnail_height > $ratio_orig) {
@@ -47,9 +51,10 @@ $img = $_GET['img'];
$tmp = OC::$CONFIG_DATADIRECTORY . $img;
-header('Content-Type: image/png');
-$image = CroppedThumbnail($tmp, $box_size, $box_size);
-
-imagepng($image);
-imagedestroy($image);
-?>
+if(file_exists($tmp))
+{
+ header('Content-Type: image/png');
+ $image = CroppedThumbnail($tmp, $box_size, $box_size);
+ imagepng($image);
+ imagedestroy($image);
+} \ No newline at end of file
diff --git a/apps/gallery/lib_scanner.php b/apps/gallery/lib_scanner.php
index 30a86b7405d..871c1c38c5f 100644
--- a/apps/gallery/lib_scanner.php
+++ b/apps/gallery/lib_scanner.php
@@ -39,7 +39,7 @@ class OC_GALLERY_SCANNER {
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?');
$result = $stmt->execute(array(OC_User::getUser(), $current_album['name']));
if ($result->numRows() == 0 && count($current_album['images'])) {
- $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)');
+ $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums (`uid_owner`, `album_name`) VALUES (?, ?)');
$stmt->execute(array(OC_User::getUser(), $current_album['name']));
}
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ? AND `album_name` = ?');
@@ -50,7 +50,7 @@ class OC_GALLERY_SCANNER {
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ? AND `file_path` = ?');
$result = $stmt->execute(array($albumId, $img));
if ($result->numRows() == 0) {
- $stmt = OC_DB::prepare('REPLACE INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
+ $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_photos (`album_id`, `file_path`) VALUES (?, ?)');
$stmt->execute(array($albumId, $img));
}
}
diff --git a/apps/gallery/templates/view_album.php b/apps/gallery/templates/view_album.php
index ea2969e0110..230e2a5c21d 100644
--- a/apps/gallery/templates/view_album.php
+++ b/apps/gallery/templates/view_album.php
@@ -1,9 +1,17 @@
<?php
OC_Util::addStyle('gallery', 'styles');
OC_Util::addScript('gallery', 'album_cover');
-OC_Util::addScript( 'files_imageviewer', 'lightbox' );
-OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
+OC_Util::addScript('files_imageviewer', 'jquery.mousewheel-3.0.4.pack');
+OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack');
+OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' );
?>
+<script type="text/javascript">
+ $(document).ready(function() {
+ $("a[rel=images]").fancybox({
+ 'titlePosition': 'inside'
+ });
+ });
+</script>
<div id="controls">
<a href="?"><input type="button" value="Back" /></a><br/>
@@ -12,7 +20,7 @@ OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
<?php
foreach ($_['photos'] as $a) {
?>
-<a onclick="javascript:viewImage('/','<?php echo $a; ?>');"><img src="ajax/thumbnail.php?img=<?php echo $a ?>"></a>
+<a rel="images" href="../../files/ajax/download.php?files=<?php echo $a; ?>"><img src="ajax/thumbnail.php?img=<?php echo $a ?>"></a>
<?php
}
?>