1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 17:23:00 +00:00

Fill in video and audio previews.

This commit is contained in:
Starbeamrainbowlabs 2016-04-07 18:26:59 +01:00
parent 18012c82fe
commit ef28bc4902
4 changed files with 49 additions and 15 deletions

View file

@ -203,7 +203,7 @@ $settings->upload_allowed_file_types = [
"video/mp4",
"video/webm",
"audio/mp4",
"audio/mp3"
"audio/mpeg"
];
// The default file type for previews.
@ -221,7 +221,8 @@ $settings->mime_extension_mappings_location = "/etc/mime.types";
// Used to override the above file if it assigns weird extensions
// to any mime types.
$settings->mime_mappings_overrides = [
"text/plain" => "txt"
"text/plain" => "txt",
"audio/mpeg" => "mp3"
];
// The minimum and maximum allowed sizes of generated preview images in pixels.
@ -316,7 +317,7 @@ input[type=button], input[type=submit] { cursor: pointer; }
.sidebar li:before { content: \"\"; position: absolute; width: 1rem; top: 0.8rem; left: -1.2rem; border-bottom: 2px dashed rgba(50, 50, 50, 0.4); }
.preview { text-align: center; }
.preview img { max-width: 100%; }
.preview img, .preview video, .preview audio { max-width: 100%; }
.image-controls ul { list-style-type: none; margin: 5px; padding: 5px; }
.image-controls li { display: inline-block; margin: 5px; padding: 5px; }
.link-display { margin-left: 0.5rem; }
@ -2674,9 +2675,18 @@ register_module([
case "video":
case "audio":
$im = errorimage("TODO: Proxy the video / audio through");
header("image/png");
imagepng($im);
// Get the file size
$filesize = filesize($filepath);
// Send some headers
header("content-length: $filesize");
header("content-type: $mime_type");
// Open the file and send it to the user
$handle = fopen($filepath, "rb");
fpassthru($handle);
fclose($handle);
exit();
break;
default:
@ -2744,8 +2754,15 @@ register_module([
break;
case "video":
$preview_html .= "<video src='$previewUrl' controls preload='metadata'>Your browser doesn't support the HTML5 video tag, but you can still <a href='$previewUrl'>download it</a> if you'd like.</video>";
$preview_html .= "\t\t\t<figure class='preview'>
<video src='$previewUrl' controls preload='metadata'>Your browser doesn't support HTML5 video, but you can still <a href='$previewUrl'>download it</a> if you'd like.</video>
</figure>";
break;
case "audio":
$preview_html .= "\t\t\t<figure class='preview'>
<audio src='$previewUrl' controls preload='metadata'>Your browser doesn't support HTML5 audio, but you can still <a href='$previewUrl'>download it</a> if you'd like.</audio>
</figure>";
}
$fileInfo = [];

View file

@ -68,7 +68,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
"id": "feature-upload",
"lastupdate": 1460046939,
"lastupdate": 1460047934,
"optional": false
},
{

View file

@ -255,9 +255,18 @@ register_module([
case "video":
case "audio":
$im = errorimage("TODO: Proxy the video / audio through");
header("image/png");
imagepng($im);
// Get the file size
$filesize = filesize($filepath);
// Send some headers
header("content-length: $filesize");
header("content-type: $mime_type");
// Open the file and send it to the user
$handle = fopen($filepath, "rb");
fpassthru($handle);
fclose($handle);
exit();
break;
default:
@ -325,8 +334,15 @@ register_module([
break;
case "video":
$preview_html .= "<video src='$previewUrl' controls preload='metadata'>Your browser doesn't support the HTML5 video tag, but you can still <a href='$previewUrl'>download it</a> if you'd like.</video>";
$preview_html .= "\t\t\t<figure class='preview'>
<video src='$previewUrl' controls preload='metadata'>Your browser doesn't support HTML5 video, but you can still <a href='$previewUrl'>download it</a> if you'd like.</video>
</figure>";
break;
case "audio":
$preview_html .= "\t\t\t<figure class='preview'>
<audio src='$previewUrl' controls preload='metadata'>Your browser doesn't support HTML5 audio, but you can still <a href='$previewUrl'>download it</a> if you'd like.</audio>
</figure>";
}
$fileInfo = [];

View file

@ -200,7 +200,7 @@ $settings->upload_allowed_file_types = [
"video/mp4",
"video/webm",
"audio/mp4",
"audio/mp3"
"audio/mpeg"
];
// The default file type for previews.
@ -218,7 +218,8 @@ $settings->mime_extension_mappings_location = "/etc/mime.types";
// Used to override the above file if it assigns weird extensions
// to any mime types.
$settings->mime_mappings_overrides = [
"text/plain" => "txt"
"text/plain" => "txt",
"audio/mpeg" => "mp3"
];
// The minimum and maximum allowed sizes of generated preview images in pixels.
@ -313,7 +314,7 @@ input[type=button], input[type=submit] { cursor: pointer; }
.sidebar li:before { content: \"\"; position: absolute; width: 1rem; top: 0.8rem; left: -1.2rem; border-bottom: 2px dashed rgba(50, 50, 50, 0.4); }
.preview { text-align: center; }
.preview img { max-width: 100%; }
.preview img, .preview video, .preview audio { max-width: 100%; }
.image-controls ul { list-style-type: none; margin: 5px; padding: 5px; }
.image-controls li { display: inline-block; margin: 5px; padding: 5px; }
.link-display { margin-left: 0.5rem; }