add thumbnails
This commit is contained in:
parent
d4c22b8742
commit
fa57cb3fd4
4 changed files with 34 additions and 3 deletions
22
ajax.php
22
ajax.php
|
@ -13,6 +13,26 @@ function hasval($var){
|
|||
return isset($var) && !empty($var);
|
||||
}
|
||||
|
||||
function makethumb($hash, $width=100, $height=100, $quality = 90)
|
||||
{
|
||||
$img = getcwd()."/upload/".$hash;
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick($img);
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->cropThumbnailImage($width, $height);
|
||||
$imagick->setImagePage(0, 0, 0, 0);
|
||||
if (file_put_contents(getcwd()."/thumb/" . $hash, $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
$successmsg = "added one item";
|
||||
|
||||
switch($_GET["action"]) {
|
||||
|
@ -134,6 +154,7 @@ switch($_GET["action"]) {
|
|||
if (!$stmt->execute()) {
|
||||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
makethumb($hash);
|
||||
$successmsg = "one item edited";
|
||||
|
||||
}else{
|
||||
|
@ -177,6 +198,7 @@ switch($_GET["action"]) {
|
|||
if (!$stmt->execute()) {
|
||||
$errormsg = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
|
||||
}
|
||||
makethumb($hash);
|
||||
$successmsg = "upload ok";
|
||||
}else{
|
||||
$errormsg = "upload failed";
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="WAS" name="was" autocomplete="off">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="KISTE" name="container" autocomplete="off">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
<td><?php echo $item["was"]; ?></td>
|
||||
<td><?php echo $item["wann"]; ?></td>
|
||||
<td><?php echo $item["wo"]; ?></td>
|
||||
<td><img style="height: 48px;" src="/upload/<?php echo $item["hash"]; ?>"></td>
|
||||
<td><img style="height: 48px;" src="/thumb/<?php echo $item["hash"]; ?>"></td>
|
||||
<td>
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-outline-secondary"><i class="fas fa-fw fa-check-circle"></i></button>
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<a class="nav-link" href="../tables.html">
|
||||
<i class="fas fa-fw fa-table"></i>
|
||||
<span>Tables</span></a>
|
||||
</li-->
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/request/">
|
||||
<i class="fas fa-fw fa-comments"></i>
|
||||
|
@ -112,5 +112,11 @@
|
|||
<i class="fas fa-fw fa-plus"></i>
|
||||
<span>Item</span>
|
||||
</a>
|
||||
</li>
|
||||
</li-->
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/table/">
|
||||
<i class="fas fa-fw fa-archive"></i>
|
||||
<span>Table</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue