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