summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-07-21 12:26:16 -0700
committerBharat Mediratta <bharat@menalto.com>2009-07-21 12:26:16 -0700
commitf83db99d39cc65b212f894c7e4ed66a52625f3c8 (patch)
tree2b1f3472a42006d44a82a0cc350fceb3fa36d90b
parent8f1bca7459af7eeebb30bf116ae03c25d30836f3 (diff)
Properly display thumbnails for private movies by backtracking from
the thumbnail to the movie and then showing it as a JPG. Fixes ticket #570.
-rw-r--r--modules/gallery/controllers/file_proxy.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php
index 799260b5..a85f0a85 100644
--- a/modules/gallery/controllers/file_proxy.php
+++ b/modules/gallery/controllers/file_proxy.php
@@ -63,9 +63,22 @@ class File_Proxy_Controller extends Controller {
// We now have the relative path to the item. Search for it in the path cache
$item = ORM::factory("item")->where("relative_path_cache", $path)->find();
if (!$item->loaded) {
- // We didn't turn it up. This may mean that the path cache is out of date, so look it up
- // the hard way.
- //
+ // We didn't turn it up. It's possible that the relative_path_cache is out of date here.
+ // There was fallback code, but bharat deleted it in 8f1bca74. If it turns out to be
+ // necessary, it's easily resurrected.
+
+ // If we're looking for a .jpg then it's it's possible that we're requesting the thumbnail
+ // for a movie. In that case, the .flv or .mp4 file would have been converted to a .jpg.
+ // So try some alternate types:
+ if (preg_match('/.jpg$/', $path)) {
+ foreach (array("flv", "mp4") as $ext) {
+ $movie_path = preg_replace('/.jpg$/', ".$ext", $path);
+ $item = ORM::factory("item")->where("relative_path_cache", $movie_path)->find();
+ if ($item->loaded) {
+ break;
+ }
+ }
+ }
}
if (!$item->loaded) {
@@ -102,8 +115,13 @@ class File_Proxy_Controller extends Controller {
// We don't need to save the session for this request
Session::abort_save();
- // Dump out the image
- header("Content-Type: $item->mime_type");
+ // Dump out the image. If the item is a movie, then its thumbnail will be a JPG.
+ if (in_array($item->mime_type, array("video/x-flv", "video/mp4"))) {
+ header("Content-type: image/jpeg");
+ } else {
+ print("Content-Type: $item->mime_type");
+ }
+
Kohana::close_buffers(false);
$fd = fopen($file, "rb");
fpassthru($fd);