}
$orig_path = $this->translate_path($details['directory_path']) ."/". $details['name'];
- $thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->photo_width ."_". $this->getMD5($photo);
+ $thumb_path = $this->get_thumb_path($this->cfg->photo_width, $photo);
if(!file_exists($orig_path)) {
$this->_error("Photo ". $orig_path ." does not exist!<br />\n");
/* If the thumbnail doesn't exist yet, try to create it */
if(!file_exists($thumb_path)) {
$this->gen_thumb($photo, true);
- $thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->photo_width ."_". $this->getMD5($photo);
+ $thumb_path = $this->get_thumb_path($this->cfg->photo_width, $photo);
}
/* get f-spot database meta information */
$img_name[$rows][$cols] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
$img_title[$rows][$cols] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
- $thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->thumb_width ."_". $this->getMD5($photos[$i]);
+ $thumb_path = $this->get_thumb_path($this->cfg->thumb_width, $photos[$i]);
if(file_exists($thumb_path)) {
$info = getimagesize($thumb_path);
foreach($resolutions as $resolution) {
- $thumb_path = $this->cfg->base_path ."/thumbs/". $resolution ."_". $file_md5;
+ $thumb_sub_path = substr($file_md5, 0, 2);
+ $thumb_path = $this->cfg->base_path ."/thumbs/". $thumb_sub_path ."/". $resolution ."_". $file_md5;
+
+ if(!file_exists(dirname($thumb_path))) {
+ mkdir(dirname($thumb_path), 0755);
+ }
/* if the thumbnail file doesn't exist, create it */
if(!file_exists($thumb_path)) {
} // extractTags()
+ /**
+ * returns the full path to a thumbnail
+ */
+ public function get_thumb_path($width, $photo)
+ {
+ $sub_path = substr($this->getMD5($photo), 0, 2);
+ return $this->cfg->base_path
+ . "/thumbs/"
+ . $sub_path
+ . "/"
+ . $width
+ . "_"
+ . $this->getMD5($photo);
+
+ } // get_thumb_path()
+
}
?>
if(!$this->parent->getMD5($idx)) {
$this->parent->gen_thumb($idx);
}
- $fullpath = $this->parent->cfg->base_path ."/thumbs/". $width ."_". $this->parent->getMD5($idx);
+ $fullpath = $this->parent->get_thumb_path($width, $idx);
/* if the thumb file does not exist, create it */
if(!file_exists($fullpath)) {
$this->parent->gen_thumb($idx);