summaryrefslogtreecommitdiffstatshomepage
path: root/src/wp-admin/js/media-gallery.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/wp-admin/js/media-gallery.js')
-rw-r--r--src/wp-admin/js/media-gallery.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/wp-admin/js/media-gallery.js b/src/wp-admin/js/media-gallery.js
new file mode 100644
index 0000000000..38e4f7b481
--- /dev/null
+++ b/src/wp-admin/js/media-gallery.js
@@ -0,0 +1,25 @@
+jQuery(function($){
+ $( 'body' ).bind( 'click.wp-gallery', function(e){
+ var target = $( e.target ), id, img_size;
+
+ if ( target.hasClass( 'wp-set-header' ) ) {
+ ( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
+ e.preventDefault();
+ } else if ( target.hasClass( 'wp-set-background' ) ) {
+ id = target.data( 'attachment-id' );
+ img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
+
+ jQuery.post(ajaxurl, {
+ action: 'set-background-image',
+ attachment_id: id,
+ size: img_size
+ }, function(){
+ var win = window.dialogArguments || opener || parent || top;
+ win.tb_remove();
+ win.location.reload();
+ });
+
+ e.preventDefault();
+ }
+ });
+});