Hi!
I am trying to create a website and i have most things sorted out except for the photo gallery!
I have many many pictures to post but the only thing i can think of is linking each picture individually to their thumbnails (which i also have to link manually to the gallery page!) I found a template for the gallery pages and I have been using Dreamweaver to tweak stuff. All I can think of is linking the thumbnails that i created from the larger images individually to the photo gallery template. Is there a faster way to do this? I saw something about automatic thumbnail generators that do your gallery for you and sort everything out when additional pictures are uploaded in the future.
Any help would be greatly appreciated!!!
Thank you very much in advance =)
Sincerely,
B
The code below may work but I have not tested it. Put all your files in the one folder but add th_ to the front of all the thumb filenames.
<?php
// Find all jpg images in the thumb folder and display
foreach (glob("{"th_*.jpg","th_*.JPG"}", GLOB_BRACE) as $filename) {
// Get photo size for use in the image tag
$size = getimagesize($filename);
// Path to full size image
$normal = str_replace( 'th_', '', $filename);
// Display the photos
echo "<a href=\\"$normal\\"><img src=\\"".$filename."\\" ".$size[3]." /></a>\
"; } ?>
Oh, I see!
That would automatically use the php gallery code script use the structure I already have?
Hmm, I have many pages. I’m not done my site yet, but I different html for every single page in my website - by the end, including all the photos I think that I’ll end up with something like 100 pages. However 30% of them should be for other stuff like the homepage and etc.
Thanks! I will try harder to understand how to use php first thing tomorrow!
I would guess something like:
name/pages/1/pictures
name/pages/1/thumb
<?php
$dir = '../thumb/';
// Find all jpg images in the thumb folder and display
foreach (glob($dir."{*.jpg,*.JPG}", GLOB_BRACE) as $filename) {
// Get photo size for use in the image tag
$size = getimagesize($filename);
// Path to full size image
$normal = str_replace( '../thumb/', '', $filename);
// Display the photos
echo "<a href=\\"$normal\\"><img src=\\"".$filename."\\" ".$size[3]." /></a>\
"; }
?>
1/ Your html file in folder name/pages/1/pictures will need to be a php file now - change the extension from .html to .php
2/ Save the code above as something like display.php and save in name/pages/1/pictures
3/ In your old html page which is now a php put this where you want the images to be displayed:
<?php
include 'display.php';
?>
There may be a better way of doing this if you have multiple pages as you say - how many different pages do you have?
that is so brilliant!
I’m so happy I don’t have to individually link images using dreamweaver!
Where in my html documents do I add in the code though??
Also, would using that code keep with my current layout of the page?
I have everything laid out and 12 spots on each page for where the pictures are supposed to be, I just have to link the pictures! to each “slot”.
i understand that i should create two folders, one for thumbnails and another for the actual images, but where do I save them and how do i execute your script for all my pages are supposed to be image galleries?
The site I am making is structured something like this:
html/categories/product type/subcategories/subcategory name/pages/1/pictures (in this folder i put all the pictures that i want to be on that first page)
I have a html document in the folder “1” for the photo gallery
and then for page 2 of that product I do
categories/product type/subcategories/subcategory name/pages/2/pictures
Thank you so much for taking your time to help me out! I’m extremely grateful
There are loads of code about you can use.
I call my thumbnail and full size image the same name but put into two different folders - thumbs and normal.
I then use this code to read the thumbs folder for all the images - in this case jpg images - use float ( needs adding ) to display the thumbs. When a user selects a thumb you are taken to another page with a full size image.
$dir = 'thumbs/';
// Find all jpg images in the thumbs folder and display
foreach (glob($dir."{*.jpg,*.JPG}", GLOB_BRACE) as $filename) {
// Get photo size for use in the image tag
$size = getimagesize($filename);
// Path to full size image
$normal = str_replace( 'thumb', 'normal', $filename);
// Display the photos
echo "<a href=\\"$normal\\"><img src=\\"".$filename."\\" ".$size[3]." /></a>\
"; }
Whenever a new photo is uploaded it will automaticaly be added to the list.
You can do a lot more with the code - add other image formats, add text from a file.
Thats basicly how this gallery works but with the next and back added;
My gallery
Wonderful Rubble!
Thank you SO much again!
I will put it to the test ASAP and let you know how it goes =)
On a side note, I want to give a shoutout to the user Raffles who has been a great help to me via PMs!