JavaScript
0
Вклад в тег
$(document).on('click', '.upload_image_button_photo', function(event){
event.preventDefault();
var button = $(this);
var user_id = $(button).siblings('#user_id').val();
var custom_uploader = wp.media({
button: {
text: 'Загрузить'
},
multiple: true
})
.on('select', function() {
var attachments = custom_uploader.state().get('selection').toJSON();
// console.log(attachments);
attachments.forEach(function(curVal, index, array) {
// console.log(curVal);
handlerRequestPhoto('upload_photos', 'add', user_id, curVal.url );
setTimeout(function(){
$('.photos-block').append('<div class="col-sm-3 item"><div class="single-photo"><a class="fancybox" rel="gallery" href="' + curVal.url + '"><img src="' + curVal.url + '"></a></div></div>');
}, 300);
});
})
.open();
});