-
Notifications
You must be signed in to change notification settings - Fork 0
/
media.js
32 lines (31 loc) · 1007 Bytes
/
media.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
jQuery(document).ready(function($){
var tgm_media_frame;
$(document.body).on('click.tgmOpenMediaManager', '.tgm-open-media', function(e){
e.preventDefault();
if ( tgm_media_frame ) {
tgm_media_frame.open();
return;
}
tgm_media_frame = wp.media.frames.tgm_media_frame = wp.media({
className: 'media-frame tgm-media-frame',
frame:'select',
multiple: true,
title: tgm_nmp_media.title,
library: {
type: 'image'
},
button: {
text: 'Add to Gallery'
}
});
tgm_media_frame.on('select', function(){
var selection = tgm_media_frame.state().get('selection');
selection.each(function(attachment) {
IDs = jQuery('#tgm-new-media-image').val() + ',' + attachment.id;
jQuery('#tgm-new-media-image').val(IDs);
});
update_gallery();
});
tgm_media_frame.open();
});
});