Remove link for full size and add link for full size and thumb. Few ajust style.

This commit is contained in:
Knah Tsaeb 2013-03-28 16:51:50 +01:00
parent 73f5564569
commit 7490983bb0
3 changed files with 44 additions and 23 deletions

View file

@ -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

View file

@ -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;

View file

@ -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'];
}
?>
<!DOCTYPE html>
<html>
@ -294,7 +303,7 @@ if (empty($defUrl)) {
<select name="s">
<?php
foreach ($GLOBALS['config']['thumbSize'] as $key => $value) {
if ($value === $GLOBALS['config']['defaultThumbSize']) {
if ($value === $width) {
echo '<option value="', $key, '" selected="selected">', $value, '</option>';
} else {
echo '<option value="', $key, '">', $value, '</option>';
@ -302,6 +311,8 @@ if (empty($defUrl)) {
}
?>
</select>
</p>
<p>
<label>Force refresh</label>
<input type="checkbox" value="1" name="fr" />
</p>
@ -313,16 +324,16 @@ if (empty($defUrl)) {
<a href="http://forge.leslibres.org/projects/soshot">Homepage</a>
</p>
</form>
<div id="result">
<?php
if (!empty($success)) {
if ($GLOBALS['config']['onlyThumb'] === true) {
echo '<img src="', $success['thumb'], '?r=', time(), '"/>';
} else {
echo '<a href="', $success['normal'], '"><img src="', $success['thumb'], '?r=', time(), '"/></a>';
}
<?php
if (!empty($success)) {
echo '<div id="result">';
echo '<img src="', $success['thumb'], '?r=', time(), '"/>';
echo '<p><label>', $width, '</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['thumb'], '" onclick="this.select()"/></p>';
if ($GLOBALS['config']['onlyThumb'] === false) {
echo '<p><label>1280x1024</label><input type="text" value="http://', $_SERVER['SERVER_NAME'], '/', $success['normal'], '" onclick="this.select()"/></p>';
}
?>
</div>
}
echo '</div>';
?>
</body>
</html>