...

View Full Version : photo album



Mihai
12-11-2008, 01:12 AM
i've been looking for a simple photo album script online that can generate the album from 1.jpg , 2.jpg, 3.jpg ... 600.jpg , without me adding all the files manualy or creating a xml.
Can someone tell me how i can generate a photo album like this ?

Thank you

lxculango
12-11-2008, 02:34 AM
just use the php filehandling....

scan the directory of your images..

for example..

<?php
$dir = 'images/'; // directory of your images
$dh = opendir($dir);
if($dh){
while($filename = readdir($dh)){
if(strpos($filename,'.jpg') >0 || strpos($filename,'.jpeg') >0 || strpos($filename,'.gif') >0 || strpos($filename,'.png') >0){
echo '<img src="'.$filename.'" /><br>';
}
}

}
?>

just debug that if there's error... I think that's near to the solution you want with your problem..

Mihai
12-11-2008, 03:19 AM
thank you

Jedi Knight
12-11-2008, 11:55 AM
This really works great. And so simple, too.

Could you explain how to use foreach to display the images in vertical columns in rows of 3?
Or would it be simpler to remove the < br > and use css to keep them from making one long horizontal row?


I've added a Automatic Image Resizer to this that displays the image in fullsize when you click on it.
Here's what it looks like:
http://valorsolo.com/upload/files/air-box.jpg

I'll write up some instructions and upload the necessary files if anyone wants it.

I also use it as an mp3 gallery and again as a flash gallery.

For mp3 gallery:
Place this in the head of your page.

<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>


Then find and replace:

echo '<img src="'.$filename.'" /><br>';
With:

echo '<a href="'.$url.$filename.'">'.$filename.'</a><br><br>';

For flash gallery:
Find and replace:

echo '<img src="'.$filename.'" /><br>';
With:

echo '<object><param name=movie value="'.$url.$filename.'"><embed src="'.$url.$filename.'"></embed></object><br><br><a href="'.$url.$filename.'">'.$filename.'</a><br><br>';

Jedi Knight
12-11-2008, 01:50 PM
I decided to go ahead and post the instructions in case anyone wants it.

Find:


</head>


Add this BEFORE the code above:


<!-- AIR-Box mod addition - starts here -->
<script type="text/javascript" src="mootools.js"></script>
<script type="text/javascript" src="{airbox.js"></script>
<link rel="stylesheet" href="slimbox_css/slimbox.css" type="text/css" media="screen" />
<!-- AIR-Box mod addition - ends here -->


Find:


echo '<img src="'.$filename.'" /><br>';

Replace With:


echo '<a href="'.$url.$filename.'" rel="lightbox[gallery]"><img class="postimage" src="'.$url.$filename.'" /></a><br>';


Adjusting Image Width


To set image sizes, open airbox.js
at line 22: if (pic.width > 640)

change 640 to desired number of pixel for minimum width of images to be resized.
In this case images that are less than 640px wide won't be resized,
images that are more than 640px wide will be resized to the value you can assign at line 14.(See below).
Adjust it for your layout width.

at line 24: pic.setAttribute('width','640')

change 640 to desired number of pixel for width of resized images.
Adjust it for your layout width.

As an alternative you can control width relative to document size. Read line 26.



Extract zip and upload included files to your gallery directory

LJackson
12-11-2008, 09:14 PM
this code looks very useful, i may use it for a possible future project if thats ok?

cheers
Luke

Jedi Knight
12-11-2008, 09:34 PM
this code looks very useful, i may use it for a possible future project if thats ok?

cheers
Luke

It's definitely ok with me. I hope you have as much fun with it as I am.

I'm still trying to display the images in 3 vertical columns.
Right now I have 1 vertical column.

LJackson
12-11-2008, 09:47 PM
cool thanks,

have you uploaded your page your webspace yet? if so can i have the web address so i can have a look at it and hopefully recommend a way to get 3 columns :)

cheers

Jedi Knight
12-11-2008, 10:44 PM
cool thanks,

have you uploaded your page your webspace yet? if so can i have the web address so i can have a look at it and hopefully recommend a way to get 3 columns :)

cheers

I set up a demo for you.

http://valorsolo.com/demo/gallery.php

LJackson
12-11-2008, 10:50 PM
looks cool mate, how are your images stored are you using the method above that lxculango mentioned?

Jedi Knight
12-11-2008, 11:03 PM
All image, flash and audio files are uploaded to the same directory.
Then, I use lxculango code above on 3 different files, music.php flash.php and gallery.php.
All files only fetching their respective file types.
All I did from there was dress it up with the AIR mod for the gallery.php and I used this player for music.php.

<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>

The browser takes care of the swf in flash.php.

It was alot easier than I thought it was going to be when I started.

LJackson
12-11-2008, 11:42 PM
ok what i would suggest, and its by no means the best or the quickest way but i would use a combination of css and php to do as you want, the only small worry i would have at the moment is that because your pics arnt all the same size it might look untidy if you were to go down the css root (it may not we'll have to wait and see) :)

here is a quick example of what i mean:


<?php




$dir = 'images/'; // directory of your images
$dh = opendir($dir);
if($dh){

echo '<div class="container">';
while($filename = readdir($dh)){
if(strpos($filename,'.jpg') >0 || strpos($filename,'.jpeg') >0 || strpos($filename,'.gif') >0 || strpos($filename,'.png') >0){

echo '<div class="imgcontainer">';
echo '<img src="'.$filename.'" />';
echo '</div>';
}
}

}
echo'</div>';
?>

see ive inserted some divs above i have included these in my stylesheet using the following code:


.imgcontainer{
width:250px;
height:200px;
float:left;
margin:5px;
border:1px solid #9999FF;
text-align:center;
}
.container{
width:750px;
height:800px;
float:left;
}


and this gives me this page (http://www.kernow-connect.com/affiliate/imagetest.php)(unfortunatly my images arnt loading up for some reason.)

this would be the best way that i can recommend, if you require any help with this i'd gladly help, but its getting late now and i'll be back tomorrow.

best of luck
Luke

Jedi Knight
12-12-2008, 01:14 AM
I had to do some minor adjustments, but it work out very well.
Thanks for your help.

LJackson
12-12-2008, 12:12 PM
No problems mate glad to of been able to help :)

Jedi Knight
12-15-2008, 06:03 PM
I set up a demo for you.

http://valorsolo.com/demo/gallery.php

I've been tweaking this a little, drop back by and see if it works any better.
I was playing with some dynamic frames and stuff, but it was too buggy, so I quit while I was ahead.

LJackson
12-15-2008, 06:13 PM
Hi mate, yeah its looking really nice, if i was being picky, on the images and flash pages the container that the images are in is wider than the page so you have to scroll accross to see the last picture.

if you can make them the same width as your header it would look nicer, try and reduce the margin of the image container so that all the pics fit in :)

but thats the only "little" improvment i'd make if its possible :)

keep up the good work
cheers
Luke

Jedi Knight
12-15-2008, 10:12 PM
I'm not experiencing this in IE7, FF or Opera.
The header and the image container are the same size and aren't wider than the page here.
I've also minimized my browsers to mimic other resolutions.
It all works for me.

I'm not sure why we are getting different results, but I won't be able to fix it until I can duplicate the problem on my end.

LJackson
12-16-2008, 12:57 AM
fair enough mate, im using IE7 on windows vista.

just checked it on FF and it is fine seems to be a IE thing. not ure what to suggest mate, ive run a validator check and it has returned 19 errors which may seem a lot but its not ive had over 140 errors on 1 page before :)

solving these may help you site display properly on all browsers

here (http://validator.w3.org/check?uri=http%3A%2F%2Fvalorsolo.com%2Fdemo%2Fgallery.php&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.606)is the result from your page.

best of luck!!
Luke

Jedi Knight
12-16-2008, 12:26 PM
I found an extra head tag that shouldn't have been there.

Other than that, almost all the errors were no alt tags on the images.
And the break tags were not needed, all taken care of and passed validation.
See if it works in IE7 for you now.

And thanks for running the validation on it.

LJackson
12-16-2008, 02:25 PM
Hi mate,

the image gallery page is now fixed :) but you will need to do the same for the flash gallery page as its still the same.

here (http://validator.w3.org/check?uri=http%3A%2F%2Fvalorsolo.com%2Fdemo%2Fflash.php&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.606)is the validation results for that page :)

no worries mate its a handy tool to use :)
all the best
Luke

Jedi Knight
12-16-2008, 07:16 PM
Yeah, I used the gallery page as a template for the flash page.
I only worked on the gallery and not the flash to see if it was the code causing the issue.
I'll fix all the other pages up later this evening. I'm working on another site, as well.

I'm glad we finally got it going, thanks for all the help and guidance.

LJackson
12-16-2008, 10:04 PM
No probs mate any time :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum