mirror of
https://github.com/Fluffy-Bean/image-gallery.git
synced 2025-02-05 21:18:03 +00:00
Added thumbnails and resolution to image info
This commit is contained in:
parent
fda00c7c31
commit
29eda68d8f
23
image.php
23
image.php
|
@ -28,14 +28,14 @@
|
|||
$image = mysqli_fetch_assoc($image_results);
|
||||
|
||||
if ($image['imagename'] != "") {
|
||||
$image_name = "images/".$image['imagename'];
|
||||
$image_path = "images/".$image['imagename'];
|
||||
$image_alt = $image['alt'];
|
||||
}else{
|
||||
$image_name = "assets/no_image.png";
|
||||
$image_path = "assets/no_image.png";
|
||||
$image_alt = "No image could be found, sowwy";
|
||||
}
|
||||
|
||||
echo "<img class='image' id='".$image['id']."' src='".$image_name."' alt='".$image_alt."'>";
|
||||
echo "<img class='image' id='".$image['id']."' src='".$image_path."' alt='".$image_alt."'>";
|
||||
|
||||
if (!isset($_GET['id'])) {
|
||||
echo "cannot obtain image";
|
||||
|
@ -46,16 +46,31 @@
|
|||
<div class="image-description">
|
||||
<h2>Description</h2>
|
||||
<?php
|
||||
echo "<p>".$image_alt."</p>";
|
||||
// Image Description/Alt
|
||||
if ($image_alt != "") {
|
||||
echo "<p>".$image_alt."</p>";
|
||||
}else{
|
||||
echo "<p>Image uploaded prior to description being added</p>";
|
||||
}
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="image-detail flex-down">
|
||||
<h2>Details</h2>
|
||||
<?php
|
||||
// Image ID
|
||||
echo "<p>ID: ".$image['id']."</p>";
|
||||
|
||||
// File name
|
||||
echo "<p>File Name: ".$image['imagename']."</p>";
|
||||
|
||||
// Image Upload date
|
||||
echo "<p>Upload Date: ".$image['upload']."</p>";
|
||||
|
||||
// Image resolution
|
||||
list($width, $height) = getimagesize($image_path);
|
||||
echo "<p>Image resolution: ".$width."x".$height."</p>";
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
|
11
index.php
11
index.php
|
@ -42,9 +42,16 @@
|
|||
// Reading images from table
|
||||
$img = mysqli_query($conn, "SELECT * FROM swag_table");
|
||||
while ($row = mysqli_fetch_array($img)) {
|
||||
echo "<div class='gallery-item'>";
|
||||
// Getting thumbnail
|
||||
if (file_exists("images/thumbnails/".$row['imagename'])) {
|
||||
$image_path = "images/thumbnails/".$row['imagename'];
|
||||
}else{
|
||||
$image_path = "images/".$row['imagename'];
|
||||
}
|
||||
|
||||
// Image loading
|
||||
echo "<a href='https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$row['id']."'><img class='gallery-image' loading='lazy' src='images/".$row['imagename']."' id='".$row['id']."'></a>";
|
||||
echo "<div class='gallery-item'>";
|
||||
echo "<a href='https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$row['id']."'><img class='gallery-image' loading='lazy' src='".$image_path."' id='".$row['id']."'></a>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
// If image present, continue
|
||||
if ($get_image_name != "") {
|
||||
// Set file path for image upload
|
||||
$image_path = "images/".basename($get_image_name);
|
||||
$image_basename = basename($get_image_name);
|
||||
$image_path = "images/".$image_basename;
|
||||
$sql = "INSERT INTO swag_table (imagename, alt) VALUES ('$get_image_name','$get_alt_text')";
|
||||
|
||||
|
||||
|
@ -65,6 +66,11 @@
|
|||
|
||||
// Checking if image uploaded
|
||||
if (move_uploaded_file($_FILES['image']['tmp_name'], $image_path)) {
|
||||
// Make thumbnail
|
||||
$image_thumbnail = new Imagick($image_path);
|
||||
$image_thumbnail->resizeImage(300,null,null,1,null);
|
||||
$image_thumbnail->writeImage("images/thumbnails/".$image_basename);
|
||||
|
||||
header("Location:upload.php?r=success");
|
||||
}else{
|
||||
header("Location:upload.php?r=fail");
|
||||
|
|
Loading…
Reference in a new issue