* @param integer $idx
* @param integer $width
*/
- public function showImg($idx, $width = 0)
+ public function showImg($idx, $width = 0, $version = NULL)
{
if($idx == 'rand')
$idx = $this->parent->get_random_photo();
- $details = $this->parent->get_photo_details($idx);
-
+ /* display the lastest available version, if a wrong version has been requested */
+ if(!isset($version) || !$this->parent->is_valid_version($idx, $version))
+ $version = $this->parent->get_latest_version($idx);
+
+ $details = $this->parent->get_photo_details($idx, $version);
+
if(!$details) {
$this->parent->showTextImage("The image (". $idx .") you requested is unknown");
return;
}
/* show thumbnail */
else {
- /* if no entry for this photo is yet in the database, create thumb */
+
+ if(!$this->parent->is_valid_width($width)) {
+ $this->parent->showTextImage("Requested width ". $width ."px is not valid!");
+ return;
+ }
+ /* check for an entry if we already handled this photo before. If not,
+ create a thumbnail for it.
+ */
if(!$this->parent->getMD5($idx)) {
$this->parent->gen_thumb($idx);
}
- $fullpath = $this->parent->get_thumb_path($width, $idx);
+ /* get the full filesystem path to the thumbnail */
+ $fullpath = $this->parent->get_thumb_path($width, $idx, $version);
/* if the thumb file does not exist, create it */
if(!file_exists($fullpath)) {
$this->parent->gen_thumb($idx);
if(!$this->parent->getMD5($idx)) {
$this->parent->gen_thumb($idx);
}
- $fullpath = $this->parent->get_thumb_path($width, $idx);
+
+ $version = $this->parentÂ>get_latest_version($idx);
+
+ $fullpath = $this->parent->get_thumb_path($width, $idx, $version);
/* if the thumb file does not exist, create it */
if(!file_exists($fullpath)) {
$this->parent->gen_thumb($idx);
$img = new PHPFSPOT_IMG;
if(isset($_GET['width']) && is_numeric($_GET['width']))
- $img->showImg($_GET['idx'], $_GET['width']);
+ $width = $_GET['width'];
+ else
+ $width = NULL;
+
+ if(isset($_GET['version']) && is_numeric($_GET['version']))
+ $version = $_GET['version'];
else
- $img->showImg($_GET['idx']);
+ $version = NULL;
+
+ $img->showImg($_GET['idx'], $width, $version);
exit(0);
}
}
-
?>