Build An Automated PHP Gallery System In Minutes

sorvin did you make it work ?

Thanks Hisham, that worked out well. :slight_smile: I’m still unable to get the date to display on the thumbnail listing though.

am having problem integrating it to the code
i get thumb and a black image.

you welcome

some problem while integrating it .

ok ok its been solved. actually problem at my end.

ok would you care to share your solution with me and rest of SP members :slight_smile:

In reply to a PM from an SP member i integrated the watermarking script into his code, that was pretty much original! Below is the code which should work with most people scripts. Note that you need to place it immediatly after you copy the image from the TMP dir to within your site.


// Store the orignal file
copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename);
 
// Watermark the original file
//////////////////////////////// WATERMARK SCRIPT ////////////////////////////////////////
///////// Courtesy of Rob Guard (www.infizi.com // rob@infizi.com) and Sitepoint /////////
// Requires GD Image Lib 1.8++ //
$my_watermark = "watermark.png"; // Must be PNG-24 Format - Create in photoshop using a trasparent background - set the image layer trasparency to around 40%

$margin = 5; // px margin around watermark
$my_image = $images_dir."/".$filename;

// Get the watermark image, load it in to a variable and get its size.
$watermark = imagecreatefrompng($my_watermark);
$w = getimagesize($watermark_image);

// Create the read and write functions for the new image
$function_suffix = $gd_function_suffix[$filetype];
$Create = 'ImageCreateFrom' . $function_suffix;
$Save = 'Image' . $function_suffix;

// Load in Image to be watermarked
$image = $Create($my_image);
$image_size = getimagesize($my_image);

// Total width - watermark width - margin gives co-ordinates for the watermark.
$dest_x = $size[0] - $w[0] - $margin;
$dest_y = $size[1] - $w[1] - $margin;

// Merge the images
imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $w[0], $w[1]);

// Save $image to $my_image
$Save($image, $my_image);

//Destroy TMP files
imagedestroy($image);
imagedestroy($watermark);

////////////////////////////////  END WATERMARK   ////////////////////////////////////////

I guess I’m a tad bit stupid… I can’t get the watermark to show… youre supposed to put the watermark file itself in the root where all the php files are, right? Cuz it aint showing…

thanks infizi for the code

am having problem make it work as well

What would be the best way to format the photo date to a month-year format? I’ve tried using substr but it didn’t work, I feel like such a noob. :frowning:

is the date your using a php time stamp? ro is it already formatted? Please give us an example of the date you want to change!

My bad, the date is in 0000-00-00 00:00:00 format gotten from the sql command now(). I would like it in 00-0000 format.

I don’t have to time to read the whole thread to ask if this has been quested/done before, so sorry if it has.

Woudln’t it be much easier to make it all into a class, so you can use it for other things, or use it to make an admin zone for it ?

I’m wanting to make it into a class, but i don’t have much exeircence with OOP, so any help or tips are welcome.

well, short of using mktime() to make a time stamp and then formatting that, i would do the following and use explode (not substr):


<?
$date_parts = explode("-", $date);
$new_date = $date_parts[1]."-".$date_parts[0];

you could always use inset the date.


  <?php
  
  	$today = date("m-Y");
  
  ?>
  

that will output “06-2006” (mm-yyyy).

but if you need the time stamp aswell the above example will do.

Hey,

I tried making it into a calss, and it does work, but you need a whole lot of front end code. This project is aimed at first time PHPers looking to extend their knowledge a little bit, hence giving them a class file and telling them what does what requires an intemediate level as they need to understand OOP. Quite like you actually. The idea is good, i added functions like $mygallery->getrandomimages(no of images[, categoryspecific]). Fantastic function that allowed me to add random images, and with a little tweaking creating functions like $mygallery->getlatestimages(noimages[,catspecific])

Its all great, but unless you understand OOP enough to make it yourself, you wont understand another persons OOP implementation and you wont be able to create pages with it.

I suggest if you really want this in OOP, sticking with that standard code, and slowly building a class by taking out repetative code etc etc an creating a class. Remember that your class will need to connect to the DB prior to any calls to it too!

If i had time i would sit and write one and send it to you, but i dont, and you wouldnt understand it without a full explanation either!

So I’m trying to add the delete function he has displayed. I want the user to click on the thumbnail and it deletes the pic. I’m having trouble excuting the delete function. Something like this would be ideal:

<A HREF=‘delete_photo($PHOTO_ID)’><IMG THUMBNAIL></A>

Any ideas?

I’ve got a problem when trying to customize my design layout. Now, we all know the default design.inc.php looks like this:

<?php

$design_header= <<<__HTML_END

<!-- Add your site header here -->
HTML DESIGN-start
__HTML_END;

$design_footer= <<<__HTML_END

<!-- Add your site footer here -->
HTML DESIGN-end
__HTML_END;
?>

Now a few obstacles im running into is this: my gallery is in the /gallery directory off the root. But I have include files, scripts, and stylesheets in their respective directories, which are also off the root. Anyway, the majority of my header code is controlled by one line:
<? include(“includes/header.php”) ?>
However, I can’t seem to add this on its own, even if I change it to have “…/” before the path. I’m also running into the same thing with my footer file is well. To make things worse, when I use brute force and inject the contents of my header.php directly into the design.inc.php, it puts all the gallery below all my design code (when everything else on the site fits nicely within).

Help!