File: 0006_Add-support-for-thumbonly.patch

package info (click to toggle)
libapache-gallery-perl 1.0.2-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,260 kB
  • sloc: perl: 1,281; sh: 21; makefile: 13
file content (53 lines) | stat: -rw-r--r-- 1,967 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Origin: 65853401c4d4bfb946aa8ddd4e543035c1102647 Mon Sep 17 00:00:00 2001
From: Don Armstrong <don@donarmstrong.com>
Last-Update: Nov 2017-11-02
Subject: Add support for thumbonly to the Debian package

---
 debian/changelog      |  1 +
 lib/Apache/Gallery.pm | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/lib/Apache/Gallery.pm b/lib/Apache/Gallery.pm
index b4575be..88a03b4 100644
--- a/lib/Apache/Gallery.pm
+++ b/lib/Apache/Gallery.pm
@@ -540,6 +540,20 @@ sub handler {
 				return $::MP2 ? Apache2::Const::FORBIDDEN() : Apache::Constants::FORBIDDEN();
 			}
 		}
+        if (defined $ENV{QUERY_STRING} && $ENV{QUERY_STRING} eq 'thumbonly' &&
+            $r->dir_config('GalleryAllowThumbonly') &&
+            -f $filename) {
+
+            my ($width, $height, $type) = imgsize($filename);
+            my @filetypes = qw(JPG TIF PNG PPM GIF);
+            if (grep $type eq $_, @filetypes) {
+                my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $width, $height);
+                my $imageinfo = get_imageinfo($r, $filename, $type, $width, $height);
+                my $cached = get_scaled_picture_name($filename, $thumbnailwidth, $thumbnailheight);
+                $r->headers_out->set(Location => uri_escape(".cache/$cached", $escape_rule));
+                return $::MP2 ? Apache2::Const::REDIRECT() : Apache::Constants::REDIRECT();
+            }
+        }
 	
 		# Create cache dir if not existing
 		my @tmp = split (/\//, $filename);
@@ -1759,6 +1773,14 @@ resizing or putting the CopyrightImage on it.
 
 Set to 1 or 0, default is 0
 
+=item B<GalleryAllowThumbOnly>
+
+If true, B<GalleryAllowThumbOnly> allows fooimg.jpg?thumbonly urls
+to output the thumbnail of the image. This is useful when including
+images in a blog (or similar).
+
+Defaults to '0' (false).
+
 =item B<GallerySlideshowIntervals>
 
 With this option you can configure which intervals can be selected for
-- 
2.51.0