Skip to content

Commit

Permalink
Accept extension .m4v as video/mp4
Browse files Browse the repository at this point in the history
  • Loading branch information
rledisez authored and bharat committed Jul 10, 2010
1 parent 9d66783 commit 39962ea
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions modules/gallery/controllers/file_proxy.php
Expand Up @@ -72,10 +72,10 @@ public function __call($function, $args) {
// 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.
// for a movie. In that case, the .flv, .mp4 or .m4v file would have been converted to a .jpg.
// So try some alternate types:
if (preg_match('/.jpg$/', $path)) {
foreach (array("flv", "mp4") as $ext) {
foreach (array("flv", "mp4", "m4v") as $ext) {
$movie_path = preg_replace('/.jpg$/', ".$ext", $encoded_path);
$item = ORM::factory("item")->where("relative_path_cache", "=", $movie_path)->find();
if ($item->loaded()) {
Expand Down
4 changes: 2 additions & 2 deletions modules/gallery/controllers/flash_uploader.php
Expand Up @@ -50,7 +50,7 @@ public function add_photo($id) {
// Uploadify adds its own field to the form, so validate that separately.
$file_validation = new Validation($_FILES);
$file_validation->add_rules(
"Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4]");
"Filedata", "upload::valid", "upload::required", "upload::type[gif,jpg,jpeg,png,flv,mp4,m4v]");

if ($form->validate() && $file_validation->validate()) {
$temp_filename = upload::save("Filedata");
Expand All @@ -63,7 +63,7 @@ public function add_photo($id) {

$path_info = @pathinfo($temp_filename);
if (array_key_exists("extension", $path_info) &&
in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
in_array(strtolower($path_info["extension"]), array("flv", "mp4", "m4v"))) {
$item->type = "movie";
$item->save();
log::success("content", t("Added a movie"),
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/models/item.php
Expand Up @@ -364,7 +364,7 @@ public function save() {
$this->name .= "." . $pi["extension"];
}

$this->mime_type = strtolower($pi["extension"]) == "mp4" ? "video/mp4" : "video/x-flv";
$this->mime_type = in_array(strtolower($pi["extension"]), array("mp4", "m4v")) ? "video/mp4" : "video/x-flv";
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/views/form_uploadify.html.php
Expand Up @@ -9,7 +9,7 @@
uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>",
script: "<?= url::site("flash_uploader/add_photo/{$album->id}") ?>",
scriptData: <?= json_encode($script_data) ?>,
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4",
fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.flv;*.mp4;*.m4v;*.GIF;*.JPG;*.JPEG;*.PNG;*.FLV;*.MP4;*.M4V",
fileDesc: <?= t("Photos and movies")->for_js() ?>,
cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>",
simUploadLimit: <?= $simultaneous_upload_limit ?>,
Expand Down
2 changes: 1 addition & 1 deletion modules/organize/controllers/organize.php
Expand Up @@ -34,7 +34,7 @@ function dialog($album_id) {
$file_filter = json_encode(
array("photo" => array("label" => "Images",
"types" => array("*.jpg", "*.jpeg", "*.png", "*.gif")),
"movie" => array("label" => "Movies", "types" => array("*.flv", "*.mp4"))));
"movie" => array("label" => "Movies", "types" => array("*.flv", "*.mp4", "*.m4v"))));

$v = new View("organize_dialog.html");
$v->album = $album;
Expand Down
6 changes: 3 additions & 3 deletions modules/server_add/controllers/server_add.php
Expand Up @@ -55,7 +55,7 @@ public function children() {
}
if (!is_dir($file)) {
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) {
if (!in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v"))) {
continue;
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ static function add($task) {
$queue[] = array($child, $entry_id);
} else {
$ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4")) &&
if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4", "m4v")) &&
filesize($child) > 0) {
$child_entry = ORM::factory("server_add_file");
$child_entry->task_id = $task->id;
Expand Down Expand Up @@ -249,7 +249,7 @@ static function add($task) {
$photo->owner_id = $owner_id;
$photo->save();
$entry->item_id = $photo->id;
} else if (in_array($extension, array("flv", "mp4"))) {
} else if (in_array($extension, array("flv", "mp4", "m4v"))) {
$movie = ORM::factory("item");
$movie->type = "movie";
$movie->parent_id = $parent->id;
Expand Down

0 comments on commit 39962ea

Please sign in to comment.