From 7490983bb0d3ea86abd4c709f37584649bade5fb Mon Sep 17 00:00:00 2001
From: Knah Tsaeb
Date: Thu, 28 Mar 2013 16:51:50 +0100
Subject: [PATCH] Remove link for full size and add link for full size and
thumb. Few ajust style.
---
bin/thumb_server.sh | 4 ++--
inc/style.css | 16 ++++++++++++---
index.php | 47 ++++++++++++++++++++++++++++-----------------
3 files changed, 44 insertions(+), 23 deletions(-)
diff --git a/bin/thumb_server.sh b/bin/thumb_server.sh
index 06b25b2..ffba1cd 100755
--- a/bin/thumb_server.sh
+++ b/bin/thumb_server.sh
@@ -49,7 +49,7 @@ then
fi
exit
fi
-if [ $onlyThumb ]
+if [ $onlyThumb == 1 ]
then
convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 -filter Lanczos -thumbnail "$thumbSize" "cache/img/$md5Site""_thumb.png"
if [ $optimizeTool ]
@@ -57,7 +57,7 @@ then
eval $optimizeTool "cache/img/$md5Site""_thumb.png"
fi
else
- convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 "cache/img/$md5Site.png" &&
+ convert "cache/tmp/$md5Site.png" -crop 1280x1024+0+0 "cache/img/$md5Site.png"
convert "cache/img/$md5Site.png" -filter Lanczos -thumbnail "$thumbSize" "cache/img/$md5Site""_thumb.png"
if [ $optimizeTool ]
then
diff --git a/inc/style.css b/inc/style.css
index a44819f..0db9793 100644
--- a/inc/style.css
+++ b/inc/style.css
@@ -6,7 +6,7 @@ html {
background-color: #dedede;
}
-form {
+form, #result{
padding: 1em;
text-align: center;
width: 50%;
@@ -20,12 +20,20 @@ input, select {
height: 2em;
}
+#result input[type=text] {
+ width: 80%;
+ display: inline-block;
+}
+
input[type=url] {
width: 100%;
}
-label {
+#result label {
margin-right: 1em;
+ width : 15%;
+ display: inline-block;
+ text-align:center;
}
form .info {
@@ -38,6 +46,7 @@ form .info {
#result {
text-align: center;
padding: 1em;
+ margin: 1em auto;
}
#result img {
@@ -52,7 +61,7 @@ form .info {
padding: 0.1em;
}
- form {
+ form, #result {
width: 100%;
padding: 0.1em;
}
@@ -69,6 +78,7 @@ form .info {
label {
display: block;
}
+
select {
width: 99%;
height: 2em;
diff --git a/index.php b/index.php
index a807ba5..0df6f38 100644
--- a/index.php
+++ b/index.php
@@ -16,8 +16,8 @@ $GLOBALS['config']['defaultUrl'] = 'https://google.com';
// default url for form
$GLOBALS['config']['defaultThumbSize'] = '120x90';
// default size for thumbnail
-$GLOBALS['config']['onlyThumb'] = true;
-// generate only thumbnail or generate thumb nail + 1280x1024 image
+$GLOBALS['config']['onlyThumb'] = TRUE;
+// generate only thumbnail or generate thumbnail + 1280x1024 image
$GLOBALS['config']['thumbSize'] = array(1 => '100x80', '120x90', '200x160', '300x240', '400x320', '500x400');
// list of available size for thumb
@@ -69,14 +69,20 @@ function testExistImg($file) {
}
}
-function launchScript($url, $md5Url, $width, $waitForResult = false) {
+function launchScript($url, $md5Url, $width, $onlyThumb, $waitForResult = false) {
$md5Url = escapeshellarg($md5Url);
$url = escapeshellarg($url);
$width = escapeshellarg($width);
- if ($waitForResult === false) {
- exec('bin/thumb_server.sh ' . $url . ' ' . $md5Url . ' ' . $width . ' ' . (bool)$GLOBALS['config']['onlyThumb'] . ' > /dev/null &', $result);
+ if ($GLOBALS['config']['onlyThumb'] === true) {
+ $onlyThumb = 1;
} else {
- exec('bin/thumb_server.sh ' . $url . ' ' . $md5Url . ' ' . $width . ' ' . (bool)$GLOBALS['config']['onlyThumb'] . ' 1', $result);
+ $onlyThumb = 0;
+ }
+
+ if ($waitForResult === false) {
+ exec('bin/thumb_server.sh ' . $url . ' ' . $md5Url . ' ' . $width . ' ' . $onlyThumb . ' > /dev/null &', $result);
+ } else {
+ exec('bin/thumb_server.sh ' . $url . ' ' . $md5Url . ' ' . $width . ' ' . $onlyThumb . ' 1', $result);
}
return $result;
}
@@ -267,7 +273,7 @@ if ($_POST) {
$file = 'cache/img/' . $md5Url;
if (testExistImg($file) !== true || isset($ui['fr']) && (int)$ui['fr'] === 1) {
- launchScript($defUrl, $md5Url, $width, true);
+ launchScript($defUrl, $md5Url, $width, $GLOBALS['config']['onlyThumb'], true);
}
$success = array('normal' => $file . '.png', 'thumb' => $file . '_thumb.png');
}
@@ -275,6 +281,9 @@ if ($_POST) {
if (empty($defUrl)) {
$defUrl = $GLOBALS['config']['defaultUrl'];
}
+if (empty($width)) {
+ $width = $GLOBALS['config']['defaultThumbSize'];
+}
?>
@@ -294,7 +303,7 @@ if (empty($defUrl)) {
+
+
@@ -313,16 +324,16 @@ if (empty($defUrl)) {
Homepage
-
- ';
- } else {
- echo '
';
- }
+ ';
+ echo '
';
+ echo '
';
+ if ($GLOBALS['config']['onlyThumb'] === false) {
+ echo '
';
}
- ?>
-
+ }
+ echo '';
+ ?>