kartik-v / yii2-widgets

Collection of useful widgets for Yii Framework 2.0
http://demos.krajee.com/widgets
Other
558 stars 175 forks source link

Manual file preview image on fileinput load #343

Open domaxas opened 7 years ago

domaxas commented 7 years ago

When my page that has a fileinput widget loads i want to manually have one image inside it. It is not uploaded yet, its just a default image that the user can remove or keep if he wants to. The code looks like this:

                $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"
                    ],
                    'uploadUrl' => Url::to(['upload-images']),
                    'maxFileCount' => 100,
                    'overwriteInitial' => false,
                    'initialPreviewAsData' => true,
                    'initialPreviewConfig' => [
                        ['caption' => 'Moon.jpg', 'size' => '873727'],
                        ['caption' => 'Earth.jpg', 'size' => '1287883'],
                    ],                        'layoutTemplates' => [
                        'actionDrag' => '',
                        'actionUpload' => '',
                    ],
                ];

The problem is that the remove button is not working, you click on it and nothing happens, no error in console too. In my opinion the event is not loaded or missing, or something(not experienced with frontend).

However, if for example i drag & drop another image next to the default one, the fileinput.js loads the event and i can remove the images i want.

Is it possible to make the remove event work before the drag & drop?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/47383267-manual-file-preview-image-on-fileinput-load?utm_campaign=plugin&utm_content=tracker%2F530581&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F530581&utm_medium=issues&utm_source=github).