PHP MySQL Tutorial
Learn PHP and MySQL

Image Gallery : Add Image

50% of people found this useful
Image Gallery : Add Image

Adding a new image is easy. Just select in which album you want the image stored, supply the image name, description, add the image and click the "Add Image" button.

Here's the form screenshot :

Gallery Admin : Add Image

The image title is limited to 64 characters however there is no restriction on the length of the image description And, you are free to use any html tags in the description.

The code for this part is very similar to the one when adding new album so i won't explain it in detail here. You could read the source code and i'm sure you'll understand. The difference is that the image is stored in GALLERY_IMG_DIR and the image icon and store it in GALLERY_IMG_DIR/thumbnail.

 

Image List

After you add a new image or when you click on "List Image" on the left navigation link you can see the list of all images. By default this page will show all images from all albums. To show images just from one album you can select the album name from the combo box on the top right corner. When you select an album it will trigger the onChange event of the combo box and call a javascript function called viewImage() along with the id of the selected album. The function will then redirect you to the appropriate list.

Gallery Admin - List Image

The javascript code is show below.

function viewImage(albumId) {
   if (albumId != '') {
      window.location.href = 'index.php?page=list-image&album=' +
                              albumId;
   } else {
      window.location.href = 'index.php?page=list-image';
   }
}

When you select a specific album from the combo box the album id is sent to this function. The if block is executed and you go to the page for that specific album. But if you select the "--- All Album--" option then the value of albumId will be an empty string. The else block is executed and you'll go the the default image list.

Recent Comments

Leave the first comment for this page.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems