Skip to content

Commit

Permalink
Place thumbs in subfolder.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrsjng committed Aug 31, 2013
1 parent 5c5d050 commit cadc1f4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/_h5ai/server/php/inc/Thumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand All @@ -22,6 +23,8 @@ public static final function is_supported() {
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;
}


Expand All @@ -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)) {

Expand Down

0 comments on commit cadc1f4

Please sign in to comment.