summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-11-01 10:42:46 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-11-01 10:42:46 +0000
commit4ff4a0e7adc87e654f6eefccdd2f43827bd06535 (patch)
tree6b8c59c7186e8de76e67b3add5840897bf52bff6 /phpfspot.class.php
parentf0081bb8b3aed07efd5e5a74d1481ac2a3f88e48 (diff)
issue73, new directory structure for thumbnails
git-svn-id: file:///var/lib/svn/phpfspot/trunk@275 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index b82fbee..723140f 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -292,7 +292,7 @@ class PHPFSPOT {
}
$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");
@@ -305,7 +305,7 @@ class PHPFSPOT {
/* 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 */
@@ -755,7 +755,7 @@ class PHPFSPOT {
$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);
@@ -1129,7 +1129,12 @@ class PHPFSPOT {
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)) {
@@ -1808,6 +1813,22 @@ class PHPFSPOT {
} // 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()
+
}
?>