Freeola Internet Get Dotted Domains Gaming & Extras
Freeola Gameaday
VIP Unlimited Hosting
 
Browse Chat Forums:
 Chat Forums Home Latest Message Chat Rules Chat Safety & Tips Top Posters How to Win Gameaday View the Winners List Update Your Profile See Who's Online
  Free Web Site  Free Domain Hosting  Emergency Internet  Broadband Offers
 

Help & Support 7 Days a Week

count down top left count down top count down top right
0000000000000000
base count down

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

Migrate to Freeola Broadband - absolutely Free of Charge!

nothing
Just lurking around? Why not join in? You could win free games just by chatting. Choose your Nickname in MyFreeola, or Sign Up Here.
 
you are here
chat line Freeola Chat Forums (49)
Chat Rooms & Users Online
Web Sites & Internet
"[PHP] Basic Image Ga..."
search
 
Login or Create Free Account
Create & Run Your Own Forum
Free Domain Name Transfers! Free Domain Name Transfers! Free Domain Name Transfers!
 
Browsing the Freeola Chat Forums...
 
After the original message, all posts and replies are shown in reverse order, with the most recent post at the top. i.e. your latest post will always appear under the original message, at the top of the first page.
 
To display oldest posts first, click the 'Flip Order - Oldest First' link below.
Close This Tip
 
Back To Threads Post a Reply  
 
 
[PHP] Basic Image Gallery There are 9 replies
Original Message posted by Garin on 19/07/2008 at 1:42:04AM
# 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.
 
 Replies To This Post:
 
McLong
on 22/07/2008 at 1:48:35PM
Total Posts: 174
Well done Garin :) Although I'm quite intruiged as to what Machie put in his original reply before editing it...
 
Machie
on 22/07/2008 at 12:38:41PM
Total Posts: 10530
Amended :)
 
Garin
"Devil in disguise"
on 22/07/2008 at 12:34:29PM
Total Posts: 1701
Now now, you'll never get a PHP backed folder/file protector with that sort of talk. :P
 
Machie
on 22/07/2008 at 12:15:05PM
Edited: 22/7/08 12:38
Total Posts: 10530
Congratulations on winning a GAD for this fine script Garin. I would definitely consider using it myself. :)
 
Garin
"Devil in disguise"
on 19/07/2008 at 2:46:20PM
Total Posts: 1701
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
"I don't believe it"
on 19/07/2008 at 1:58:27PM
Total Posts: 851
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"
on 19/07/2008 at 1:50:01PM
Total Posts: 1701
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?"
on 19/07/2008 at 1:23:42PM
Total Posts: 786
The links were working earlier - probably just a cheap and nasty host he's using ;¬)







Search Freeola Chat
 
Eccles
"Aargh! Broken..."
on 19/07/2008 at 1:03:34PM
Total Posts: 400
Sounds good but your demo and script links are dead (from here anyway).
 
Garin
"Devil in disguise"
on 19/07/2008 at 1:42:04AM
Edited: 19/7/08 14:44
Total Posts: 1701
# 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.
 
 
MyFreeola Internet Settings Control Panel
Login or take a free look around.
Free Account Sign-Up
Freeola Gameaday
Today's Winner
Nickname: pete_21
Entry: Review Post
 
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.
OR VISIT GETDOTTED.COM