File tree 1 file changed +23
-4
lines changed
1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change 1
- ( function ( $ ) {
1
+ jQuery ( document ) . ready ( function ( $ ) {
2
2
$ ( '.pw-gallery' ) . each ( function ( ) {
3
3
var instance = this ;
4
4
5
5
$ ( 'input[type=button]' , instance ) . click ( function ( ) {
6
6
var gallerysc = '[gallery ids="' + $ ( 'input[type=hidden]' , instance ) . val ( ) + '"]' ;
7
7
wp . media . gallery . edit ( gallerysc ) . on ( 'update' , function ( g ) {
8
8
var id_array = [ ] ;
9
- $ . each ( g . models , function ( id , img ) { id_array . push ( img . id ) ; } ) ;
10
- $ ( 'input[type=hidden]' , instance ) . val ( id_array . join ( "," ) ) ;
9
+ var fileGroup = [ ] ;
10
+
11
+ $ ( ".cmb2-media-status li" ) . remove ( ) ;
12
+
13
+ $ . each ( g . models , function ( id , img ) {
14
+
15
+ id_array . push ( this . id ) ;
16
+ var width = this . attributes . sizes . thumbnail . width ? this . attributes . sizes . thumbnail . width : 150 ;
17
+ var height = this . attributes . sizes . thumbnail . height ? this . attributes . sizes . thumbnail . height : 150 ;
18
+
19
+ uploadStatus = '<li class="img-status"><img width="' + width + '" height="' + height + '" src="' + this . attributes . sizes . thumbnail . url + '" class="attachment-150x150" alt=""></li>' ;
20
+ fileGroup . push ( uploadStatus ) ;
21
+
22
+ } ) ;
23
+
24
+ $ ( 'input[type=hidden]' , instance ) . val ( id_array . join ( "," ) ) ;
25
+
26
+ $ ( fileGroup ) . each ( function ( ) {
27
+
28
+ $ ( '.cmb2-media-status' ) . slideDown ( ) . append ( this ) ;
29
+ } ) ;
11
30
} ) ;
12
31
} ) ;
13
32
} ) ;
14
- } ( jQuery ) ) ;
33
+ } ) ;
You can’t perform that action at this time.
0 commit comments