[PHP] Basic Image Gallery
Freeola Internet Get Dotted Domains Chat & Gaming
Freeola Gaming
Free 360 Games
Freeola Games HomeChat ForumsCheatsWalkthroughsTips & TrophiesReviewsWin Free GamesMyFreeolainvader-bob
£50,000 Domain Giveaway. Get Your FREE .info Domain Name Today!
 
Browse Chat Forums:
 Chat Forums Home View Latest Post Chat Rules Chat Safety & Tips Top Posters
  Games Homepage  Win Free Games  Latest Winners  Hall of Fame  See Who's Online  Update Your Profile
  Free Web Site  Free Domain Hosting  Emergency Internet  Broadband Offers  Broadband Speed Test
 

Did you know...?

Premium Customer Support

Win Amazon Vouchers!

Visit our Support Pages E-mail a Support Request Contact Us

Build Your Own Web Site In Minutes!

nothing
You Are Here Chat Home (38)   Web Development & Technical Chat  [PHP] Basic Image Ga...
Just lurking around? Why not join in? You could win free games just by chatting. Choose your Nickname in MyFreeola or Sign Up Here.
 
 
 General Chat     Web and Technical Chat     Games Chat     Game Reviews   
 
[PHP] Basic Image Gallery
"Devil in disguise"
Regular
on 19/07/2008 at 1:42:04AM
Edited: 19/7/08 14:44
Total Posts: 2074
Original Post:
# WHAT THIS SCRIPT DOES #


It displays images from a designated directory in a gallery format.  Thumbnails of images are created automatically and cached for future use.  There is also some simple support for providing titles and descriptions of the images in a text file.

Demos: Demo1 Demo2

Code (as a text file): source code
Formatted Code (for browsing online only) : source code


# HOW TO USE THIS PHP GALLERY #

- First of all you'll need some pictures, this gallery supports gif, jpeg and png file formats.

- Upload your images to an appropriate folder on your hosting.  Within that folder you need to created a directory called thumbs where the thumbnails will be stored.  After you have created the thumbs folder you need to change its permissions (ie CHMOD it) so that the PHP script is allowed to write into it.  The permissions you need are 755.  However depending on your host you might need 777 instead.

- Image descriptions can be placed in a text file called descriptions.txt and uploaded to the thumbs folder you created. To add a description you should place a line in your text file like this..
Image file<tab>Image Title<tab><Image Description>
eg..
mypicture.jpg    My Picture    This is a description of my picture.

You should place 1 description per line.

- Next we can configure the gallery script itself...

- Grab the script from here and save it with a php file extension.

-Add your own HTML
Replace <!--HTML HEADER--> and <!--HTML FOOTER--> with your own HTML (eg your site navigation/frame etc.)

-The CSS the gallery uses is also in gallery.php.  Either move it to a separate css file or place it in the head tag of your HTML frame.  There are only a few styles applied, of course you can add to this as you see fit to get the style you want.

-Next you need to configure, all the config variables are clearly marked near the top of the code.
-Path to your images:

$galleryDirectory='my/absolute/path/goes/here';

You need to change my/absolute/path/goes/here to point to the directory that will contain the pictures that will be displayed in the gallery.  For instance if you created a folder called gallery in your root directory then you'd simply change the path to gallery.  Or if within that gallery folder you created a folder called my_first_gallery, then your path would be 'gallery/my_first_gallery'.  Note you dont need a leading /.

-Thumbnail size.
Directly below the gallery path are 2 variables that define the thumbnail sizes.
$maxWidth=100;
$maxHeight=100;


100 is the height and width in pixels the thumbnails will be.  Change these as you see fit, but remember to update the height and widths defined in the css styles.

-Thumbnail style
$fixedSize=true;
This can be set to either true or false.  If set to true then the thumbnail are of a fixed size.  Any resized images that are smaller than the thumbnail dimensions are then centred within that area.  You can see both effects in the demos.  Demo 1 shows the gallery with $fixedsize=false and demo 2 shows it with true.

-Background colour (this is only applicable if fixedSize is set to true)
$backgroundColour='000000'; dictates the background colour of the thumbnail. It is a standard html RGB hexidecimal value eg CD65A0, AABBFF.  This is the colour thats shown when the thumbnail doesnt cover the entire area of the fixed size thumbnail.

Tada! Hopefully you have a working gallery.

I'm not the greatest at writing descriptions but hopefully you've been able to follow it.  If theres any bugs in the code, I definitely did it on purpose. :P

With a bit of basic knowledge its fairly easy to extend this as well.  You can integrate it with something like lightbox or thickbox quite simply for instance.
View More Threads Post a Reply  
Displaying 1 - 10 of 10 Replies:
adrian_hampshi...
Regular
on 24/06/2009 at 12:06:28AM
Total Posts: 1
Hey, very nice work. Great little gallery system here. I have a question...could you add a way to display a next and previous button once the thumbnail is enlarged? This would be a great addition to speed up image viewing. I would GREATLY appreciate any help with that. Thx.
McLong
Staff
on 22/07/2008 at 1:48:35PM
Total Posts: 367
Well done Garin :) Although I'm quite intruiged as to what Machie put in his original reply before editing it...
Machie
Regular
on 22/07/2008 at 12:38:41PM
Total Posts: 11592
Amended :)
Garin
"Devil in disguise"
Regular
on 22/07/2008 at 12:34:29PM
Total Posts: 2074
Now now, you'll never get a PHP backed folder/file protector with that sort of talk. :P
Machie
Regular
on 22/07/2008 at 12:15:05PM
Edited: 22/7/08 12:38
Total Posts: 11592
Congratulations on winning a GAD for this fine script Garin. I would definitely consider using it myself. :)
Garin
"Devil in disguise"
Regular
on 19/07/2008 at 2:46:20PM
Total Posts: 2074
Ok, changed hosts.  As of now its all working.  I cant make any guarantees about 5 minutes from now.

This is what you get for not using Freeola, nothing but trouble. :)
Dragonlance
"Bordo della verita"
Regular
on 19/07/2008 at 1:58:27PM
Total Posts: 1502
Garin wrote:
> I'm losing the will to live trying to find a working free host.
> So far I think I've spent more time trying to get some free
> hosting than writing the script. :)
>
> Anyway, I'll find somewhere else.

Script links work but demo links only show image 'place holders', if that's of any help:)
Garin
"Devil in disguise"
Regular
on 19/07/2008 at 1:50:01PM
Total Posts: 2074
I'm losing the will to live trying to find a working free host.  So far I think I've spent more time trying to get some free hosting than writing the script. :)

Anyway, I'll find somewhere else.
Hmmm...
"Are you sure?"
Moderator
on 19/07/2008 at 1:23:42PM
Total Posts: 1692
The links were working earlier - probably just a cheap and nasty host he's using ;¬)







Search Freeola Chat
Eccles
"Aargh! Broken..."
Staff Moderator
Send a message
on 19/07/2008 at 1:03:34PM
Total Posts: 702
Sounds good but your demo and script links are dead (from here anyway).
Garin
"Devil in disguise"
Regular
on 19/07/2008 at 1:42:04AM
Edited: 19/7/08 14:44
Total Posts: 2074
# WHAT THIS SCRIPT DOES #


It displays images from a designated directory in a gallery format.  Thumbnails of images are created automatically and cached for future use.  There is also some simple support for providing titles and descriptions of the images in a text file.

Demos: Demo1 Demo2

Code (as a text file): source code
Formatted Code (for browsing online only) : source code


# HOW TO USE THIS PHP GALLERY #

- First of all you'll need some pictures, this gallery supports gif, jpeg and png file formats.

- Upload your images to an appropriate folder on your hosting.  Within that folder you need to created a directory called thumbs where the thumbnails will be stored.  After you have created the thumbs folder you need to change its permissions (ie CHMOD it) so that the PHP script is allowed to write into it.  The permissions you need are 755.  However depending on your host you might need 777 instead.

- Image descriptions can be placed in a text file called descriptions.txt and uploaded to the thumbs folder you created. To add a description you should place a line in your text file like this..
Image file<tab>Image Title<tab><Image Description>
eg..
mypicture.jpg    My Picture    This is a description of my picture.

You should place 1 description per line.

- Next we can configure the gallery script itself...

- Grab the script from here and save it with a php file extension.

-Add your own HTML
Replace <!--HTML HEADER--> and <!--HTML FOOTER--> with your own HTML (eg your site navigation/frame etc.)

-The CSS the gallery uses is also in gallery.php.  Either move it to a separate css file or place it in the head tag of your HTML frame.  There are only a few styles applied, of course you can add to this as you see fit to get the style you want.

-Next you need to configure, all the config variables are clearly marked near the top of the code.
-Path to your images:

$galleryDirectory='my/absolute/path/goes/here';

You need to change my/absolute/path/goes/here to point to the directory that will contain the pictures that will be displayed in the gallery.  For instance if you created a folder called gallery in your root directory then you'd simply change the path to gallery.  Or if within that gallery folder you created a folder called my_first_gallery, then your path would be 'gallery/my_first_gallery'.  Note you dont need a leading /.

-Thumbnail size.
Directly below the gallery path are 2 variables that define the thumbnail sizes.
$maxWidth=100;
$maxHeight=100;


100 is the height and width in pixels the thumbnails will be.  Change these as you see fit, but remember to update the height and widths defined in the css styles.

-Thumbnail style
$fixedSize=true;
This can be set to either true or false.  If set to true then the thumbnail are of a fixed size.  Any resized images that are smaller than the thumbnail dimensions are then centred within that area.  You can see both effects in the demos.  Demo 1 shows the gallery with $fixedsize=false and demo 2 shows it with true.

-Background colour (this is only applicable if fixedSize is set to true)
$backgroundColour='000000'; dictates the background colour of the thumbnail. It is a standard html RGB hexidecimal value eg CD65A0, AABBFF.  This is the colour thats shown when the thumbnail doesnt cover the entire area of the fixed size thumbnail.

Tada! Hopefully you have a working gallery.

I'm not the greatest at writing descriptions but hopefully you've been able to follow it.  If theres any bugs in the code, I definitely did it on purpose. :P

With a bit of basic knowledge its fairly easy to extend this as well.  You can integrate it with something like lightbox or thickbox quite simply for instance.
 
Your Details MyFreeola Internet Settings Control Panel Your Details
Login or create a free account.
Forgotten your password?
Free Account Sign-Up
 
Your Details
Search
 
 
 
Fantastic FREE Unlimited Services for every freeola internet customer in the UK!
Register Domain Names. Buy from £2.99
e.g. yourcompany.com
or just yourcompany.
MORE ABOUT DOMAIN NAMES