mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-29 01:34:31 +01:00
fix webm for multiimage
This commit is contained in:
parent
ada00495e2
commit
8acee0f43a
@ -5,43 +5,43 @@
|
||||
function postHandler($post) {
|
||||
global $board, $config;
|
||||
|
||||
if ($post->has_file && $post->extension == 'webm') {
|
||||
if ($post->has_file) foreach ($post->files as &$file) if ($file->extension == 'webm') {
|
||||
require_once dirname(__FILE__) . '/videodata.php';
|
||||
$videoDetails = videoData($post->file_path);
|
||||
$videoDetails = videoData($file->file_path);
|
||||
if (!isset($videoDetails['container']) || $videoDetails['container'] != 'webm') return "not a WebM file";
|
||||
|
||||
// Set thumbnail
|
||||
$thumbName = $board['dir'] . $config['dir']['thumb'] . $post->file_id . '.webm';
|
||||
$thumbName = $board['dir'] . $config['dir']['thumb'] . $file->file_id . '.webm';
|
||||
if ($config['spoiler_images'] && isset($_POST['spoiler'])) {
|
||||
// Use spoiler thumbnail
|
||||
$post->thumb = 'spoiler';
|
||||
$file->thumb = 'spoiler';
|
||||
$size = @getimagesize($config['spoiler_image']);
|
||||
$post->thumbwidth = $size[0];
|
||||
$post->thumbheight = $size[1];
|
||||
$file->thumbwidth = $size[0];
|
||||
$file->thumbheight = $size[1];
|
||||
} elseif (isset($videoDetails['frame']) && $thumbFile = fopen($thumbName, 'wb')) {
|
||||
// Use single frame from video as pseudo-thumbnail
|
||||
fwrite($thumbFile, $videoDetails['frame']);
|
||||
fclose($thumbFile);
|
||||
$post->thumb = $post->file_id . '.webm';
|
||||
$file->thumb = $file->file_id . '.webm';
|
||||
} else {
|
||||
// Fall back to file thumbnail
|
||||
$post->thumb = 'file';
|
||||
$file->thumb = 'file';
|
||||
}
|
||||
unset($videoDetails['frame']);
|
||||
|
||||
// Set width and height
|
||||
if (isset($videoDetails['width']) && isset($videoDetails['height'])) {
|
||||
$post->width = $videoDetails['width'];
|
||||
$post->height = $videoDetails['height'];
|
||||
if ($post->thumb != 'file' && $post->thumb != 'spoiler') {
|
||||
$file->width = $videoDetails['width'];
|
||||
$file->height = $videoDetails['height'];
|
||||
if ($file->thumb != 'file' && $file->thumb != 'spoiler') {
|
||||
$thumbMaxWidth = $post->op ? $config['thumb_op_width'] : $config['thumb_width'];
|
||||
$thumbMaxHeight = $post->op ? $config['thumb_op_height'] : $config['thumb_height'];
|
||||
if ($videoDetails['width'] > $thumbMaxWidth || $videoDetails['height'] > $thumbMaxHeight) {
|
||||
$post->thumbwidth = min($thumbMaxWidth, intval(round($videoDetails['width'] * $thumbMaxHeight / $videoDetails['height'])));
|
||||
$post->thumbheight = min($thumbMaxHeight, intval(round($videoDetails['height'] * $thumbMaxWidth / $videoDetails['width'])));
|
||||
$file->thumbwidth = min($thumbMaxWidth, intval(round($videoDetails['width'] * $thumbMaxHeight / $videoDetails['height'])));
|
||||
$file->thumbheight = min($thumbMaxHeight, intval(round($videoDetails['height'] * $thumbMaxWidth / $videoDetails['width'])));
|
||||
} else {
|
||||
$post->thumbwidth = $videoDetails['width'];
|
||||
$post->thumbheight = $videoDetails['height'];
|
||||
$file->thumbwidth = $videoDetails['width'];
|
||||
$file->thumbheight = $videoDetails['height'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user