Implemented loading images to the product card using this Demo plugin.

Plug on gita

How can I substitute in the field previews previously uploaded images when editing a product card, to further add or delete images?

PHP Array of images with paths and sizes available. How to transfer it to JS-processing (Mb JSON type)?

Or send on the right path please ...

$("#image").fileinput({ uploadUrl: '#', showPreview: true, browseOnZoneClick: true, browseLabel: 'Выбрать изображения &hellip;', removeLabel: 'Очистить', removeTitle: 'Удалить все файлы', previewFileType: "image", allowedFileTypes: ["image"], allowedFileExtension: ['jpg', 'jpeg', 'png'], overwriteInitial: false, showCaption: false, showRemove: true, showUpload: false, maxFilePreviewSize: 1000, maxFileSize: 1000, maxFileNum: 15, initialPreviewAsData: true, initialPreview: [ <?php if (! empty($imgArray)) : ?> <?php foreach ($imgArray as $image) : ?> '<?= 'http://zend-mvc.loc/'. $image; ?>', <?php endforeach; ?> <?php endif; ?> ] }); 

    1 answer 1

    When initializing the plugin, install

     initialPreview: [ '<img src="/path_to_file.jpg">', '<img src="/path_to_file2.jpg">', ], 
    • Thanks, but how can I get a PHP array with file names? - Drakulitka
    • Can an example be initialized? - lyhoshva September
    • Substitute an array with the names turned out, the photos are displayed. But it turns out not there digging. It is necessary that they can be edited as in the new download, so that they are the same objects when editing. - Drakulitka
    • When creating a product, you can upload files to the preview area, then delete unnecessary files and add them again before sending them to the server. - Drakulitka
    • one
      For each element, the config is written: initialPreviewConfig: [{caption: 'desert.jpg', width: '120px', url: '/ localhost / avatar / delete', key: 100,}, {caption: 'jellyfish.jpg', width: '120px', url: '/ localhost / avatar / delete', key: 101,}] url: link to delete pictures via AJAX key: id which will go post through AJAX - lyhoshva