Jump to content

Simple photo album page


paulareno

Recommended Posts

Hi,

 

I'm looking for the most simplest solution, i would just like something where i can place the images i want into a folder and a php script makes clickable thumbnails on  page, but i want it so more images can be added later without having to generate the page through a software again.

 

If any of that makes sense i hope someone can help.

 

Thanks, Paul

Link to comment
Share on other sites

This is what I would do:

 

1.  Have a form script that uploads an image and creates a thumbnail and resized large image.  Store the image names in a database table

2.  Have a page that queries the database and displays all the thumbnail images.  These would be hyperlinked images that load a large version of the image in a new page.

3.  Have a page to display the large version of the image.

 

You can add an extra level of complexity by adding pagination to display a few thumbnails per page.

 

Hope this helps

 

 

Link to comment
Share on other sites

This is not true, you don't have to 're-make' the page, you only need to refresh it, unless you use JavaScript, an in which case would allow you to use Ajax to automatically query the script every 5 minutes or something for new images.

 

A simple example:

 

<?php
$dir = dir('images');

while (($file = $dir->read()) !== false) {
 if(($file != '.') || ($file != '..')) {
   print '<img src="' . $file . '" border="0" />';
 }
}

$dir->close();
?> 

 

This is just a very basic example of how to list files in a directory. In order to dynamically resize an image to create the thumbnail, you would have to use GD Library, or ImageMagik.

 

You could also upload the images into a BLOB on a database, or just store the image paths. The possibilities are endless, it may be tough although it's worth learning!

Link to comment
Share on other sites

Asin the code im using to display the images?

If so this is what i have at the moment

<?php
$dir = dir('images\pics');

while (($file = $dir->read()) !== false) {
  if(($file != '.') || ($file != '..')) {
    print '<img src="' . $file . '" border="0" />';
  }
}

$dir->close();
?> 

 

but i also tried the code you suggested

 

<?php
$files = glob('images/*.jpg');
  foreach($files as $f){
  echo "<img src=\"imageresize.php?maxsize=200&source=".$f."\" />\n";
  }
?>

Link to comment
Share on other sites

ok couple thing to fix

 

if you want to use first code then fix like so

<?php
$dir = dir('images/pics/');

while (($file = $dir->read()) !== false) {
  if(($file != '.') || ($file != '..')) {
    print '<img src="' . $dir->path.$file . '" border="0" />';
  }
}

$dir->close();
?>

 

Even though you are setting the directory to read you still have to point to the directory for the image source.

 

second code, looking at the code above, you forgot the pics folder

<?php
$files = glob('images/pics/*.jpg');
  foreach($files as $f){
  echo "<img src=\"imageresize.php?maxsize=200&source=".$f."\" />\n";
  }
?>

 

Ray

Link to comment
Share on other sites

very strange, only loaded the first picture then the rest came up with the same thing as earlier so i tried it in internet explorer and it all worked perfectly fine, i am using the newer version of firefox maybe this has something to do with it.

 

I see you corrected my mistakes with the slashes lol my bad  :-[  it's late and im tired

 

Thank you for your time and help, i will continue to troubleshoot the images with firefox tomorrow when my brain is awake again  :) and i will try uploading it to my web server as my testing server can be a little silly at times.

 

*****EDIT******

Just checked the picture formats and it turns out that the first one that loaded was a jpeg and the rest were png, Lmao so simple but yet so complicated  :D . but still doesn't explain why it loaded in ie and not firefox  ??? hmmmm

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.