D
D
Dmitry Kim2016-06-03 11:28:31
Yii
Dmitry Kim, 2016-06-03 11:28:31

How to display file size and extra buttons in Kartik-v FileInput YII2 widget?

I can't achieve this result in any way:
cc365055dd7a4451a57948137b596fad.png
I.e. need to display a drag and drop button, a button to open a preview and a file size.
In the first demo , everything works "out of the box", the author does not make any extra settings - and everything works "as it should".
In fact, it turns out like this:
94189dcb3712488b9a8191ca1968994f.png
I think it's all about templates . I'm trying to change the template to:

'layoutTemplates' => [
  'size'   => '<span>{sizeText}</span>',
  'footer' => '<div class="file-thumbnail-footer">
                      <div class="file-caption-name" style="width:{width}">{caption}{size}</div>
                      {progress} {actions}
                    </div>',
],

And I get this:
241cc40813924e779aceb21760e78add.png
Loading images goes with a bang, it remains to do "beauty", but I can't understand something CHADNT?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-06-03
@kimono

Everything is there and detailed: demos.krajee.com/widget-details/fileinput
Specifically size:

echo FileInput::widget([
    'name' => 'attachment_49[]',
    'options'=>[
        'multiple'=>true
    ],
    'pluginOptions' => [
        'initialPreview'=>[
            "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/FullMoon2010.jpg/631px-FullMoon2010.jpg",
            "http://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Earth_Eastern_Hemisphere.jpg/600px-Earth_Eastern_Hemisphere.jpg"
        ],
        'initialPreviewAsData'=>true,
        'initialCaption'=>"The Moon and the Earth",
        'initialPreviewConfig' => [
            ['caption' => 'Moon.jpg', 'size' => '873727'],
            ['caption' => 'Earth.jpg', 'size' => '1287883'],
        ],
        'overwriteInitial'=>false,
        'maxFileSize'=>2800
    ]
]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question