Skip to content

Commit 34f01b7

Browse files
committed
Merge pull request #92 from jniggemann/master
This PR fixes the thumbnail orientation regresseion and updates both mootools and mediabox
2 parents 5d295b0 + 8c18aa1 commit 34f01b7

14 files changed

Lines changed: 1057 additions & 675 deletions

createthumb.php

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,41 @@ function sanitize($name) {
124124
}
125125

126126
// Rotate JPG pictures
127+
// for more info on orientation see
128+
// http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
129+
127130
$degrees = 0;
128131
$flip = '';
129-
if ($get_filename_type == "JPG")
130-
{
131-
if (function_exists('exif_read_data') && function_exists('imagerotate'))
132-
{
133-
$exif = exif_read_data($get_filename, 0, true);
134-
if (isset($exif['IFD0']) && isset($exif['IFD0']['Orientation']))
135-
$ort = $exif['IFD0']['Orientation'];
136-
else
137-
$ort = 0;
138-
// for more info on orientation see
139-
// http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
140-
$ort2deg = array(3=>180, 4=>180, 5=>270, 6=>270, 7=>90, 8=>90);
141-
$degrees = in_array($ort, $ort2deg) ? $ort2deg[$ort] : 0;
142-
$ort2flip = array(2, 4, 5, 7);
143-
$flip = in_array($ort, $flip2deg) ? 'vertical' : '';
132+
if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
133+
if (function_exists('exif_read_data') && function_exists('imagerotate')) {
134+
$exif = exif_read_data($_GET['filename'], 0, true);
135+
$ort = $exif['IFD0']['Orientation'];
136+
switch ($ort) {
137+
case 3: // 180 rotate right
138+
$degrees = 180;
139+
break;
140+
case 6: // 90 rotate right
141+
$degrees = 270;
142+
break;
143+
case 8: // 90 rotate left
144+
$degrees = 90;
145+
break;
146+
case 2: // flip vertical
147+
$flip = 'vertical';
148+
break;
149+
case 7: // flipped
150+
$degrees = 90;
151+
$flip = 'vertical';
152+
break;
153+
case 5: // flipped
154+
$degrees = 270;
155+
$flip = 'vertical';
156+
break;
157+
case 4: // flipped
158+
$degrees = 180;
159+
$flip = 'vertical';
160+
break;
161+
}
144162
}
145163
}
146164

css/mediaboxBlack.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
}
4242
#mbCenter img{
4343
border-radius: 4px;
44+
image-orientation: from-image;
45+
position: absolute;
46+
margin: auto;
47+
top: 0;
48+
left: 0;
49+
right: 0;
50+
bottom: 0;
4451
}
4552

4653
#mbCenter.mbLoading {

css/mediaboxWhite.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242

4343
#mbCenter img{
4444
border-radius: 4px;
45+
image-orientation: from-image;
46+
position: absolute;
47+
margin: auto;
48+
top: 0;
49+
left: 0;
50+
right: 0;
51+
bottom: 0;
4552
}
4653

4754
#mbCenter.mbLoading {

humans.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Copyright (c) 2014 Alda Marteau-Hardi <alda@leetchee.fr>
99
Copyright (c) 2014 bitbybit <crigon+github@crigon.name>
1010
Copyright (c) 2014 cyberic99 <cyberic99@users.noreply.github.com>
1111
Copyright (c) 2014 iGormilhit <igormilhit@mailoo.org>
12-
Copyright (c) 2014 Jan <jn@hz6.de>
12+
Copyright (c) 2014, 2015 Jan Niggemann <jn@hz6.de>
1313
Copyright (c) 2014 Lucas Cimon <lucas.cimon@gmail.com>
1414
Copyright (c) 2014 nodiscc <nodiscc@gmail.com>
1515
Copyright (c) 2014 Orangina Rouge <eric.watson-doqguhmm@yopmail.com>
16-
Copyright (c) 2014 Nitrux Project <http://store.nitrux.in/>
16+
Copyright (c) 2014 Nitrux Project <http://store.nitrux.in/>
Lines changed: 317 additions & 288 deletions
Large diffs are not rendered by default.

js/mootools.js

Lines changed: 0 additions & 360 deletions
This file was deleted.

js/mootools1.5.0.js

Lines changed: 528 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
From 3fc42c02b31accf49aae8f1b5e4ecc2ac3b7355f Mon Sep 17 00:00:00 2001
2+
From: Jan Niggemann <jn@hz6.de>
3+
Date: Mon, 23 Feb 2015 16:34:25 +0100
4+
Subject: [PATCH 1/2] adds lightbox image autorotation (FF >v26) Firefox
5+
respects the CSS3 property "image-rotation". This makes
6+
the lightbox squared and centeres the browser-rotated
7+
image therein.
8+
9+
---
10+
css/mediaboxBlack.css | 9 ++++++++-
11+
css/mediaboxWhite.css | 9 ++++++++-
12+
js/mediabox1.5.4.js | 16 ++++++++++++++--
13+
3 files changed, 30 insertions(+), 4 deletions(-)
14+
15+
diff --git a/css/mediaboxBlack.css b/css/mediaboxBlack.css
16+
index 9213688..e4e7fde 100644
17+
--- a/css/mediaboxBlack.css
18+
+++ b/css/mediaboxBlack.css
19+
@@ -41,10 +41,17 @@
20+
}
21+
#mbCenter img{
22+
border-radius: 4px;
23+
+ image-orientation: from-image;
24+
+ position: absolute;
25+
+ margin: auto;
26+
+ top: 0;
27+
+ left: 0;
28+
+ right: 0;
29+
+ bottom: 0;
30+
}
31+
32+
#mbCenter.mbLoading {
33+
- background: #000 url(../images/loading-dark.gif) no-repeat center;
34+
+ background: #000 url(../images/loading2.gif) no-repeat center;
35+
/* This style is applied only during animation. */
36+
/* For example, the next lines turn off shadows */
37+
/* improving browser performance on slow systems. */
38+
diff --git a/css/mediaboxWhite.css b/css/mediaboxWhite.css
39+
index de9d439..7a62a90 100644
40+
--- a/css/mediaboxWhite.css
41+
+++ b/css/mediaboxWhite.css
42+
@@ -42,10 +42,17 @@
43+
44+
#mbCenter img{
45+
border-radius: 4px;
46+
+ image-orientation: from-image;
47+
+ position: absolute;
48+
+ margin: auto;
49+
+ top: 0;
50+
+ left: 0;
51+
+ right: 0;
52+
+ bottom: 0;
53+
}
54+
55+
#mbCenter.mbLoading {
56+
- background: #fff url(../images/loading-light.gif) no-repeat center;
57+
+ background: #fff url(../images/WhiteLoading.gif) no-repeat center;
58+
/* This style is applied only during animation. */
59+
/* For example, the next lines turn off shadows */
60+
/* improving browser performance on slow systems. */
61+
diff --git a/js/mediabox1.5.4.js b/js/mediabox1.5.4.js
62+
index 821e599..9e1f04f 100644
63+
--- a/js/mediabox1.5.4.js
64+
+++ b/js/mediabox1.5.4.js
65+
@@ -815,6 +815,16 @@ var Mediabox;
66+
if (mediaType == "img"){
67+
mediaWidth = preload.width;
68+
mediaHeight = preload.height;
69+
+
70+
+ // Hack jn@hz6.de: make lightbox squared to make room for the image (that will be properly rotated by the browser [at least FF since v26])
71+
+ if (mediaWidth >= mediaHeight) {
72+
+ mediaHeight = mediaWidth
73+
+ }
74+
+
75+
+ if (mediaWidth < mediaHeight) {
76+
+ mediaWidth = mediaHeight
77+
+ }
78+
+
79+
if (options.imgBackground) {
80+
media.setStyles({backgroundImage: "url("+URL+")", display: ""});
81+
} else { // Thanks to Dusan Medlin for fixing large 16x9 image errors in a 4x3 browser
82+
@@ -829,7 +839,9 @@ var Mediabox;
83+
}
84+
if (Browser.ie) preload = document.id(preload);
85+
if (options.clickBlock) preload.addEvent('mousedown', function(e){ e.stop(); }).addEvent('contextmenu', function(e){ e.stop(); });
86+
- media.setStyles({backgroundImage: "none", display: ""});
87+
+
88+
+ // Hack jn@hz6.de: Make position relative to work together with centered image (which is absolutely placed)
89+
+ media.setStyles({backgroundImage: "none", display: "", position: "relative"});
90+
preload.inject(media);
91+
}
92+
// mediaWidth += "px";
93+
@@ -973,4 +985,4 @@ Mediabox.scanPage = function() {
94+
});
95+
};
96+
97+
-window.addEvents({domready: Mediabox.scanPage, resize: Mediabox.recenter}); // to recenter the overlay while scrolling, add "scroll: Mediabox.recenter" to the object
98+
\ No newline at end of file
99+
+window.addEvents({domready: Mediabox.scanPage, resize: Mediabox.recenter}); // to recenter the overlay while scrolling, add "scroll: Mediabox.recenter" to the object
100+
--
101+
1.7.10.4
102+
103+
104+
From 7a11265131c002dbef0940d036105e05b07b9311 Mon Sep 17 00:00:00 2001
105+
From: Jan Niggemann <jn@hz6.de>
106+
Date: Mon, 23 Feb 2015 16:39:33 +0100
107+
Subject: [PATCH 2/2] fixes spinner filenames
108+
109+
---
110+
css/mediaboxBlack.css | 2 +-
111+
css/mediaboxWhite.css | 2 +-
112+
2 files changed, 2 insertions(+), 2 deletions(-)
113+
114+
diff --git a/css/mediaboxBlack.css b/css/mediaboxBlack.css
115+
index e4e7fde..95963cd 100644
116+
--- a/css/mediaboxBlack.css
117+
+++ b/css/mediaboxBlack.css
118+
@@ -51,7 +51,7 @@
119+
}
120+
121+
#mbCenter.mbLoading {
122+
- background: #000 url(../images/loading2.gif) no-repeat center;
123+
+ background: #000 url(../images/loading-dark.gif) no-repeat center;
124+
/* This style is applied only during animation. */
125+
/* For example, the next lines turn off shadows */
126+
/* improving browser performance on slow systems. */
127+
diff --git a/css/mediaboxWhite.css b/css/mediaboxWhite.css
128+
index 7a62a90..3d9f2d4 100644
129+
--- a/css/mediaboxWhite.css
130+
+++ b/css/mediaboxWhite.css
131+
@@ -52,7 +52,7 @@
132+
}
133+
134+
#mbCenter.mbLoading {
135+
- background: #fff url(../images/WhiteLoading.gif) no-repeat center;
136+
+ background: #fff url(../images/loading-light.gif) no-repeat center;
137+
/* This style is applied only during animation. */
138+
/* For example, the next lines turn off shadows */
139+
/* improving browser performance on slow systems. */
140+
--
141+
1.7.10.4
142+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
You access your MinigalNano exclusively with firefox >v26 (for example
2+
on your home server)?
3+
4+
If you apply this patch, the images in the lightbox are properly rotated
5+
by the browser itself using the information from the EXIF data.
6+
7+
To fit the images, I made the lightbox squared so there are white
8+
stripes either on the sides or the top and the bottom.
9+
10+
Jan
11+
(jn@hz6.de)

templates/board.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@
166166

167167
<script src="<% gallery_root %>js/lazy.js"></script>
168168
<script src="<% gallery_root %>js/script.js"></script>
169-
<script src="<% gallery_root %>js/mootools.js"></script>
170-
<script src="<% gallery_root %>js/mediabox1.3.4.js"></script>
169+
<script src="<% gallery_root %>js/mootools1.5.0.js"></script>
170+
<script src="<% gallery_root %>js/mediabox1.5.4.js"></script>
171171
</head>
172172
<body>
173173
<header id="top" role="banner">

0 commit comments

Comments
 (0)