Added Webm / MP4 Support

This commit is contained in:
Lain Iwakura 2016-09-09 04:56:51 -04:00
parent 9e44b0dc6a
commit 5e90e63199
3 changed files with 21 additions and 5 deletions

View File

@ -12,6 +12,8 @@ trait PostFileMethods
'image/jpg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif',
'video/webm' => 'webm',
'video/mp4' => 'mp4',
'application/x-shockwave-flash' => 'swf'
];
@ -331,9 +333,12 @@ trait PostFileMethods
$this->tempfile_name = pathinfo($this->tempfile_name, PATHINFO_FILENAME);
list ($x, $y, $type) = getimagesize($this->tempfile_path());
$this->mime_type = image_type_to_mime_type($type);
// list ($x, $y, $type) = getimagesize($this->tempfile_path());
// $this->mime_type = image_type_to_mime_type($type);
list ($x, $y) = getimagesize($this->tempfile_path());
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$this->mime_type = finfo_file($finfo, $this->tempfile_path());
finfo_close($finfo);
}
# Assigns a CGI file to the post. This writes the file to disk and generates a unique file name.
@ -414,6 +419,10 @@ trait PostFileMethods
return $this->file_ext == "swf";
}
public function video()
{
return in_array($this->file_ext, array('mp4', 'webm'));
}
public function gif()
{
return $this->file_ext == 'gif';
@ -715,4 +724,4 @@ trait PostFileMethods
$this->source = $source;
}
}
}
}

View File

@ -30,6 +30,13 @@
</object>
<p><?= $this->linkTo($this->t('post_flash_dl'), $this->post->file_url()) ?></p>
<?php elseif ($this->post->video()) : ?>
<div>
<video controls="true" autoplay="true" loop="true" >
<source src="<?= $this->post->file_url() ?>" type="video/mp4">
Your browser does not support webm video.
</video>
</div>
<?php else: ?>
<h2><a href="<?= $this->post->file_url() ?>"><?= $this->t('post_download') ?></a></h2>
<p><?= $this->t('post_download_text') ?></p>

File diff suppressed because one or more lines are too long