Merge pull request #4607 from humhub/fix/imagePreviewOnFluidTheme

Fixed image preview size on fluid themes.
This commit is contained in:
Lucas Bartholemy 2020-11-09 10:49:27 +01:00 committed by GitHub
commit 8cd11d330d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 53 deletions

View File

@ -1,6 +1,10 @@
HumHub Changelog
================
1.7.0 (Unreleased)
------------------------
- Fix #4607: Changed grid size of image preview on fluid themes
1.7.1 (Unreleased)
------------------

View File

@ -2,6 +2,7 @@
use humhub\modules\file\libs\FileHelper;
use humhub\modules\file\widgets\FilePreview;
use humhub\modules\ui\view\helpers\ThemeHelper;
use humhub\widgets\JPlayerPlaylistWidget;
use yii\helpers\Html;
@ -28,69 +29,71 @@ foreach($files as $file) {
$fullWidthColumnClass = 'col-media col-xs-12 col-sm-12 col-md-12';
$oneThirdColumnClass = 'col-media col-xs-6 col-sm-4 col-md-4';
$oneForthColumnClass = 'col-media col-xs-6 col-sm-4 col-md-2';
$galleryColumnClass = ThemeHelper::isFluid() ? $oneForthColumnClass : $oneThirdColumnClass;
?>
<?php if (count($files) > 0) : ?>
<!-- hideOnEdit mandatory since 1.2 -->
<div class="hideOnEdit">
<!-- Show Images as Thumbnails -->
<!-- hideOnEdit mandatory since 1.2 -->
<div class="hideOnEdit">
<!-- Show Images as Thumbnails -->
<?php if($showPreview) :?>
<div class="post-files clearfix" id="post-files-<?= $object->getUniqueId() ?>">
<?php if($showPreview) :?>
<div class="post-files clearfix" id="post-files-<?= $object->getUniqueId() ?>">
<?php if(!empty($audios)) : ?>
<div class="<?= $fullWidthColumnClass ?>">
<?= JPlayerPlaylistWidget::widget(['playlist' => $audios]) ?>
</div>
<?php endif; ?>
<?php foreach ($videos as $video): ?>
<?php if (FileHelper::getExtension($video->file_name) === 'webm'): ?>
<?php if(!empty($audios)) : ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.webm" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/webm" controls preload="metadata" height="130"></video>
</a>
</div>
<?php elseif (FileHelper::getExtension($video->file_name) === 'mp4'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.mp4" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/mp4" controls preload="metadata" height="130"></video>
</a>
</div>
<?php elseif (FileHelper::getExtension($video->file_name) === 'ogv'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.ogv" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/ogg" controls preload="metadata" height="130"></video>
</a>
</div>
<?php elseif (FileHelper::getExtension($video->file_name) === 'mov'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.mov" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/quicktime" controls preload="metadata" height="130"></video>
</a>
<?= JPlayerPlaylistWidget::widget(['playlist' => $audios]) ?>
</div>
<?php endif; ?>
<?php endforeach ?>
<?php foreach ($images as $image): ?>
<?php $previewImage->applyFile($image) ?>
<div class="<?= $oneThirdColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId(); ?>" href="<?= $image->getUrl() ?>#.jpeg" title="<?= Html::encode($image->file_name) ?>">
<?= $previewImage->render() ?>
</a>
</div>
<?php endforeach; ?>
<?php foreach ($videos as $video): ?>
<?php if (FileHelper::getExtension($video->file_name) === 'webm'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.webm" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/webm" controls preload="metadata" height="130"></video>
</a>
</div>
<?php elseif (FileHelper::getExtension($video->file_name) === 'mp4'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.mp4" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/mp4" controls preload="metadata" height="130"></video>
</a>
</div>
<?php elseif (FileHelper::getExtension($video->file_name) === 'ogv'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.ogv" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/ogg" controls preload="metadata" height="130"></video>
</a>
</div>
<?php elseif (FileHelper::getExtension($video->file_name) === 'mov'): ?>
<div class="<?= $fullWidthColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId() ?>" href="<?= $video->getUrl(); ?>#.mov" title="<?= Html::encode($video->file_name) ?>">
<video src="<?= $video->getUrl() ?>" type="video/quicktime" controls preload="metadata" height="130"></video>
</a>
</div>
<?php endif; ?>
<?php endforeach ?>
</div>
<?php endif; ?>
<?php foreach ($images as $image): ?>
<?php $previewImage->applyFile($image) ?>
<div class="<?= $galleryColumnClass ?>">
<a data-ui-gallery="<?= 'gallery-' . $object->getUniqueId(); ?>" href="<?= $image->getUrl() ?>#.jpeg" title="<?= Html::encode($image->file_name) ?>">
<?= $previewImage->render() ?>
</a>
</div>
<?php endforeach; ?>
<!-- Show List of all files -->
<?= FilePreview::widget([
'excludeMediaFilesPreview' => $excludeMediaFilesPreview,
'items' => $files,
'model' => $object,
]) ?>
</div>
<?php endif; ?>
</div>
<!-- Show List of all files -->
<?= FilePreview::widget([
'excludeMediaFilesPreview' => $excludeMediaFilesPreview,
'items' => $files,
'model' => $object,
]) ?>
</div>
<?php endif; ?>