Page MenuHomePhabricator

D11297.id27144.diff
No OneTemporary

D11297.id27144.diff

diff --git a/src/applications/files/config/PhabricatorFilesConfigOptions.php b/src/applications/files/config/PhabricatorFilesConfigOptions.php
--- a/src/applications/files/config/PhabricatorFilesConfigOptions.php
+++ b/src/applications/files/config/PhabricatorFilesConfigOptions.php
@@ -29,6 +29,10 @@
'audio/x-wav' => 'audio/x-wav',
'application/ogg' => 'application/ogg',
'audio/mpeg' => 'audio/mpeg',
+ 'video/mp4' => 'video/mp4',
+ 'video/ogg' => 'video/ogg',
+ 'video/webm' => 'video/webm',
+
);
$image_default = array(
@@ -47,6 +51,12 @@
'audio/mpeg' => true,
);
+ $video_default = array(
+ 'video/mp4' => true,
+ 'video/ogg' => true,
+ 'video/webm' => true,
+ );
+
// largely lifted from http://en.wikipedia.org/wiki/Internet_media_type
$icon_default = array(
// audio file icon
@@ -107,6 +117,12 @@
pht(
'List of MIME types which can be used to render an '.
'`<audio />` tag.')),
+ $this->newOption('files.video-mime-types', 'set', $video_default)
+ ->setSummary(pht('Configure which MIME types are video.'))
+ ->setDescription(
+ pht(
+ 'List of MIME types which can be used to render a '.
+ '`<video />` tag.')),
$this->newOption('files.icon-mime-types', 'wild', $icon_default)
->setSummary(pht('Configure which MIME types map to which icons.'))
->setDescription(
diff --git a/src/applications/files/controller/PhabricatorFileInfoController.php b/src/applications/files/controller/PhabricatorFileInfoController.php
--- a/src/applications/files/controller/PhabricatorFileInfoController.php
+++ b/src/applications/files/controller/PhabricatorFileInfoController.php
@@ -221,6 +221,20 @@
}
$finfo->addProperty(pht('Viewable Image'), $image_string);
+
+
+ // Is Video
+ $is_video = $file->isVideo();
+ if ($is_video) {
+ $video_string = pht('Yes');
+ $cache_string = $file->getCanCDN() ? pht('Yes') : pht('No');
+ } else {
+ $video_string = pht('No');
+ $cache_string = pht('Not Applicable');
+ }
+
+ $finfo->addProperty(pht('Viewable Video'), $video_string);
+
$finfo->addProperty(pht('Cacheable'), $cache_string);
$storage_properties = new PHUIPropertyListView();
@@ -286,6 +300,23 @@
->addImageContent($audio);
$box->addPropertyList($media);
+ } else if ($file->isVideo()) {
+ $video = phutil_tag(
+ 'video',
+ array(
+ 'controls' => 'controls',
+ 'class' => 'phui-property-list-video',
+ ),
+ phutil_tag(
+ 'source',
+ array(
+ 'src' => $file->getViewURI(),
+ 'type' => $file->getMimeType(),
+ )));
+ $media = id(new PHUIPropertyListView())
+ ->addImageContent($video);
+
+ $box->addPropertyList($media);
}
}
diff --git a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
--- a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
+++ b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
@@ -35,6 +35,7 @@
$is_viewable_image = $object->isViewableImage();
$is_audio = $object->isAudio();
+ $is_video = $object->isVideo();
$force_link = ($options['layout'] == 'link');
$options['viewable'] = ($is_viewable_image || $is_audio);
@@ -43,6 +44,8 @@
return $this->renderImageFile($object, $handle, $options);
} else if ($is_audio && !$force_link) {
return $this->renderAudioFile($object, $handle, $options);
+ } else if ($is_video && !$force_link) {
+ return $this->renderVideoFile($object, $handle, $options);
} else {
return $this->renderFileLink($object, $handle, $options);
}
@@ -196,6 +199,35 @@
)));
}
+ private function renderVideoFile(
+ PhabricatorFile $file,
+ PhabricatorObjectHandle $handle,
+ array $options) {
+
+ if (idx($options, 'autoplay')) {
+ $preload = 'auto';
+ $autoplay = 'autoplay';
+ } else {
+ $preload = 'none';
+ $autoplay = null;
+ }
+
+ return $this->newTag(
+ 'video',
+ array(
+ 'controls' => 'controls',
+ 'preload' => $preload,
+ 'autoplay' => $autoplay,
+ 'loop' => idx($options, 'loop') ? 'loop' : null,
+ ),
+ $this->newTag(
+ 'source',
+ array(
+ 'src' => $file->getBestURI(),
+ 'type' => $file->getMimeType(),
+ )));
+ }
+
private function renderFileLink(
PhabricatorFile $file,
PhabricatorObjectHandle $handle,
diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php
--- a/src/applications/files/storage/PhabricatorFile.php
+++ b/src/applications/files/storage/PhabricatorFile.php
@@ -646,6 +646,16 @@
return idx($mime_map, $mime_type);
}
+ public function isVideo() {
+ if (!$this->isViewableInBrowser()) {
+ return false;
+ }
+
+ $mime_map = PhabricatorEnv::getEnvConfig('files.video-mime-types');
+ $mime_type = $this->getMimeType();
+ return idx($mime_map, $mime_type);
+ }
+
public function isTransformableImage() {
// NOTE: The way the 'gd' extension works in PHP is that you can install it
// with support for only some file types, so it might be able to handle
diff --git a/webroot/rsrc/css/core/remarkup.css b/webroot/rsrc/css/core/remarkup.css
--- a/webroot/rsrc/css/core/remarkup.css
+++ b/webroot/rsrc/css/core/remarkup.css
@@ -192,6 +192,14 @@
width: 50%;
}
+.phabricator-remarkup video {
+ display: block;
+ margin: 16px auto;
+ min-width: 240px;
+ width: 50%;
+ max-height:700px;
+}
+
.phabricator-remarkup-mention-exists {
font-weight: bold;
background: #e6f3ff;
diff --git a/webroot/rsrc/css/phui/phui-property-list-view.css b/webroot/rsrc/css/phui/phui-property-list-view.css
--- a/webroot/rsrc/css/phui/phui-property-list-view.css
+++ b/webroot/rsrc/css/phui/phui-property-list-view.css
@@ -157,6 +157,14 @@
min-width: 240px;
}
+.phui-property-list-video {
+ display: block;
+ margin: 16px auto;
+ width: 50%;
+ min-width: 240px;
+ max-height:700px;
+}
+
/* When tags appear in property lists, give them a little more vertical
spacing. */
.phui-property-list-view .phui-tag-view {

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 27, 9:04 AM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704212
Default Alt Text
D11297.id27144.diff (6 KB)

Event Timeline