Ejemplo n.º 1
0
 public static function TagFirstFileOutput($id = 0, $options = [], $urlOnly = false)
 {
     $awsConfig = \Yii::$app->getModule('filemanager')->aws;
     $url = \Yii::$app->getModule('filemanager')->url;
     $path = \Yii::$app->getModule('filemanager')->path;
     $fileTag = FileTag::findOne($id);
     if (!$fileTag) {
         return null;
     }
     if (!isset($fileTag->firstfile[0])) {
         return null;
     }
     if ($urlOnly) {
         $return = $url . $fileTag->firstfile[0]->url;
     } else {
         $return = Html::img($url . $fileTag->firstfile[0]->url, $options);
     }
     return $return;
 }
Ejemplo n.º 2
0
echo Html::endTag('div');
echo Html::submitButton('<i class="glyphicon glyphicon-search"></i>', ['class' => 'btn btn-primary']);
ActiveForm::end();
?>

                    <div class="clearfix"></div>
                </div>

                <div class="panel-body">
                    <div class="display-images" id="fileGridManager">
                        <div class="row">
                            <?php 
$models = $dataProvider->getModels();
foreach ($models as $m) {
    echo '<div class="col-xs-6 col-sm-4 col-md-3 image-thumbnail">';
    echo Html::a('<img src="' . $path . $m->thumbnail_url . '" style="height:' . $this->context->module->thumbnails[0][1] . 'px;">', ['view', 'id' => $m->id], ['class' => 'thumbnail', 'data-id' => $m->id]);
    echo '</div>';
}
?>
                        </div>
                    </div>
                    <div class="upload-images" id="filemanagerUpload">
                        <?php 
echo FileUploadUI::widget(['model' => $model, 'attribute' => 'file_name', 'url' => ['files/upload'], 'options' => ['accept' => 'image/*', 'done' => 'filemanager'], 'clientOptions' => ['maxFileSize' => 2000000], 'clientEvents' => ['fileuploaddone' => 'function(e, data) {
                                        console.log(data);
                                        $.each(data.result.files, function( index, value ){
                                            console.log(value);
                                            $("#fileGridManager .row").prepend(\'<div class="col-xs-6 col-sm-4 col-md-3 image-thumbnail"><a class="thumbnail" href="' . Url::to(['view']) . '?id=\' + value.id + \'" data-id="\' + value.id + \'"><img src="\' + value.thumbnailUrl + \'"></a></div>\');
                                            $(\'#filemanagerUpload\').hide();
                                            $(\'#fileGridManager,#fileGridFooter\').show();
                                        });