i am having a problem with my wordpress media uploader, i am selecting multiple images but the problem is that, i can't figure out how to concatenate all the object's keys to a single string to store into database, any help will be appreciated, thanks in advance...
P.S. i have tried $.each but it returns an error, cannot use property of undefined.
ONE MORE THING: i tried console.log on the variable "attachment.url" and this is the log:
http://localhost/wp3/wp-content/uploads/2015/01/long-shadow-logo-example.jpg
admin.js?ver=4.0.1:16 http://localhost/wp3/wp-content/uploads/2015/01/Firefox.png
admin.js?ver=4.0.1:16 http://localhost/wp3/wp-content/uploads/2015/01/fish-logo-designs-32.png
but when i try to add this value to a textbox, only a single url is returned.
Here is my JS Code:
jQuery(document).on("click", ".custom_media_upload", function(e) {
e.preventDefault();
var custom_uploader = wp.media({
title: 'Select Images to Use',
button: {
text: 'Use Selected Images',
},
multiple: true // Set this to true to allow multiple files to be selected
})
custom_uploader.on('select', function() {
var selection = custom_uploader.state().get('selection');
selection.map(function(attachment) {
attachment = attachment.toJSON();
console.log(attachment.url);
});
//custom_uploader.open();
});
custom_uploader.open();
});