PHP Classes

File: views/d3filedownload/file_download.php

Recommend this page to a friend!
  Classes of Uldis Nelsons   d3files   views/d3filedownload/file_download.php   Download  
File: views/d3filedownload/file_download.php
Role: Example script
Content type: text/plain
Description: Example script
Class: d3files
Output widgets to handle uploaded files using YII2
Author: By
Last change:
Date: 5 years ago
Size: 865 bytes
 

Contents

Class file image Download
<?php
use yii\helpers\Html;
use
yii\bootstrap\Modal;

$imageExtensions = Yii::$app->getModule('d3files')->imageExtensions;
$fileExtension = pathinfo($fileName, PATHINFO_EXTENSION);

if (
in_array($fileExtension, $imageExtensions)) {
   
Modal::begin(['id' => 'modal-image', 'size' => 'modal-lg']);
    echo
Html::img(
        [
$downloadUrl, 'id' => $fileModelId],
        [
'style' => 'max-width: 100%; max-height: 100%']
    );
   
Modal::end();

    echo
Html::a(
       
Html::img(
            [
$downloadUrl, 'id' => $fileModelId],
            [
'style' => 'width: 100px;',]
        ),
       
'#',
        [
'data-toggle' => 'modal', 'data-target' => '#modal-image']
    );
} else {
    echo
Html::a(
       
Yii::t('d3files', 'Download') . ' ' . $fileName,
        [
$downloadUrl, 'id' => $fileModelId],
        [
'title' => Yii::t('d3files', 'Download')]
    );
}