Skip to content
Browse files

Place thumbs in subfolder.

  • Loading branch information...
1 parent 5c5d050 commit cadc1f49983e63b724a47d7ea91e63c1504880e9 @lrsjng committed Aug 31, 2013
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/_h5ai/server/php/inc/Thumb.php
View
11 src/_h5ai/server/php/inc/Thumb.php
@@ -4,6 +4,7 @@ class Thumb {
private static $FFMPEG_CMD = "ffmpeg -i [SOURCE] -an -ss 3 -vframes 1 [TARGET]";
private static $CONVERT_CMD = "convert -strip [SOURCE][0] [TARGET]";
+ private static $THUMB_CACHE = "thumbs";
public static final function is_supported() {
@@ -22,6 +23,8 @@ class Thumb {
public function __construct($app) {
$this->app = $app;
+ $this->thumbs_path = $this->app->get_cache_abs_path() . "/" . Thumb::$THUMB_CACHE;
+ $this->thumbs_href = $this->app->get_cache_abs_href() . Thumb::$THUMB_CACHE;
}
@@ -47,9 +50,13 @@ private function thumb_href($source_abs_path, $mode, $width, $height) {
return null;
}
+ if (!is_dir($this->thumbs_path)) {
+ @mkdir($this->thumbs_path, 0755, true);
+ }
+
$name = "thumb-" . sha1("$source_abs_path-$width-$height-$mode") . ".jpg";
- $thumb_abs_path = $this->app->get_cache_abs_path() . "/" . $name;
- $thumb_abs_href = $this->app->get_cache_abs_href() . $name;
+ $thumb_abs_path = $this->thumbs_path . "/" . $name;
+ $thumb_abs_href = $this->thumbs_href . "/" . $name;
if (!file_exists($thumb_abs_path) || filemtime($source_abs_path) >= filemtime($thumb_abs_path)) {

0 comments on commit cadc1f4

Please sign in to comment.
Something went wrong with that request. Please try again.