Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make thumbnails of videos work.

This is a bit of a kludge that needs more cleanup, but
if the cache holds an unsized version of a file, it is fed
instead of searching for the proper sized version of a file.

This makes it easy to request .thm files or recoded video
formats without passing more flags to image.php.
  • Loading branch information...
commit 22e4cf7f4102ac1fe496812fc72faf5107e5e55f 1 parent d79ce20
@sofar authored
Showing with 47 additions and 31 deletions.
  1. +31 −19 album.js
  2. +16 −12 image.php
View
50 album.js
@@ -86,26 +86,38 @@ function preload(a, i, size) {
preloads[preloads.length - 1].src = imgurl(a, i, size);
}
-function format_is_supported(name) {
+function format_is_supported(a, i) {
+ name = albums[a].images[i].name;
// Test compatibility for these per browser
- if (name.match(".ogv"))
- return supports_ogg;
- if (name.match(".OGV"))
- return supports_ogg;
- if (name.match(".mp4"))
- return (supports_mpeg4 || supports_h264);
- if (name.match(".MP4"))
- return (supports_mpeg4 || supports_h264);
-
- // Always hide these files:
- if (name.match(".mpg"))
- return false;
- if (name.match(".MPG"))
- return false;
- if (name.match(".avi"))
- return false;
- if (name.match(".AVI"))
+ if ((name.match(".ogv")) && supports_ogg)
+ return true;
+ if ((name.match(".OGV")) && supports_ogg)
+ return true;
+ if ((name.match(".mp4")) && (supports_mpeg4 || supports_h264))
+ return true;
+ if ((name.match(".MP4")) && (supports_mpeg4 || supports_h264))
+ return true;
+
+ // try and support all non-altable formats
+ if (!albums[a].images[i].alts)
+ return true;
+
+ // Check for supported alts:
+ if ((name.match(".mpg")) ||
+ (name.match(".MPG")) ||
+ (name.match(".mpeg")) ||
+ (name.match(".MPEG")) ||
+ (name.match(".avi")) ||
+ (name.match(".AVI"))) {
+ for (z = 0; z < albums[a].images[i].alts.length; z++) {
+ alt = albums[a].images[i].alts[z];
+ if ((alt.match(".ogv")) && supports_ogg)
+ return true;
+ if ((alt.match(".mp4")) && (supports_mpeg4 || supports_h264))
+ return true;
+ }
return false;
+ }
// The rest is always supported
return true;
@@ -672,7 +684,7 @@ for (x = 0; x < albums.length; x++) {
for (y = albums[x].images.length - 1; y >= 0; y--) {
if (!albums[x].images[y])
continue;
- if (!format_is_supported(albums[x].images[y].name))
+ if (!format_is_supported(x, y))
albums[x].images.splice(y, 1);
}
}
View
28 image.php
@@ -125,29 +125,33 @@ function pass_file_and_exit($file) {
if ($size > $max_size)
$size = $max_size;
+#header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($obj)).' GMT', true, 200);
+header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200);
+
$cache_path = $cache_base . "/" . $album;
-$cache_file = $cache_path . "/" . "x" . $size . "-" . basename($image);
if (!is_dir($cache_path))
mkdir($cache_path);
-header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($obj)).' GMT', true, 200);
-header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (80640 * 180)) . ' GMT', true, 200);
-
-$i = pathinfo($image);
-$ext = strtolower($i['extension']);
-
# fetch the (already rotated) cached file if present
+$cache_file = $cache_path . "/" . basename($image);
+if (file_exists($cache_file))
+ pass_file_and_exit($cache_file);
+$cache_file = $cache_path . "/" . "x" . $size . "-" . basename($image);
if (file_exists($cache_file))
pass_file_and_exit($cache_file);
+$i = pathinfo($image);
+$ext = strtolower($i['extension']);
-$exif = exif_read_data($obj, 0, true);
$o = 0;
-if (is_array($exif)) {
- if (array_key_exists('IFD0', $exif)) {
- if (array_key_exists('Orientation', $exif['IFD0'])) {
- $o = $exif['IFD0']['Orientation'];
+if (exif_imagetype($obj) != false) {
+ $exif = exif_read_data($obj, 0, true);
+ if (is_array($exif)) {
+ if (array_key_exists('IFD0', $exif)) {
+ if (array_key_exists('Orientation', $exif['IFD0'])) {
+ $o = $exif['IFD0']['Orientation'];
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.