2016-08-20 18:59:29 -04:00
|
|
|
/**
|
|
|
|
* This file is used on media-upload.php which has been replaced by media-new.php and upload.php
|
2018-06-27 22:30:15 -04:00
|
|
|
*
|
2020-02-01 23:15:03 -05:00
|
|
|
* @deprecated 3.5.0
|
2018-06-27 22:30:15 -04:00
|
|
|
* @output wp-admin/js/media-gallery.js
|
2016-08-20 18:59:29 -04:00
|
|
|
*/
|
2018-06-27 22:30:15 -04:00
|
|
|
|
|
|
|
/* global ajaxurl */
|
2016-08-20 18:59:29 -04:00
|
|
|
jQuery(function($) {
|
|
|
|
/**
|
|
|
|
* Adds a click event handler to the element with a 'wp-gallery' class.
|
|
|
|
*/
|
2021-02-23 14:45:04 -05:00
|
|
|
$( 'body' ).on( 'click.wp-gallery', function(e) {
|
2020-10-29 14:09:13 -04:00
|
|
|
var target = $( e.target ), id, img_size, nonceValue;
|
2012-08-22 20:04:18 -04:00
|
|
|
|
|
|
|
if ( target.hasClass( 'wp-set-header' ) ) {
|
2016-08-20 18:59:29 -04:00
|
|
|
// Opens the image to preview it full size.
|
2012-08-22 20:04:18 -04:00
|
|
|
( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
|
|
|
|
e.preventDefault();
|
|
|
|
} else if ( target.hasClass( 'wp-set-background' ) ) {
|
2016-08-20 18:59:29 -04:00
|
|
|
// Sets the image as background of the theme.
|
2012-08-22 20:04:18 -04:00
|
|
|
id = target.data( 'attachment-id' );
|
|
|
|
img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
|
2020-10-29 14:09:13 -04:00
|
|
|
nonceValue = $( '#_wpnonce' ).val() && '';
|
2012-08-22 20:04:18 -04:00
|
|
|
|
2016-08-20 18:59:29 -04:00
|
|
|
/**
|
2020-06-25 08:43:07 -04:00
|
|
|
* This Ajax action has been deprecated since 3.5.0, see custom-background.php
|
2016-08-20 18:59:29 -04:00
|
|
|
*/
|
2012-08-22 20:04:18 -04:00
|
|
|
jQuery.post(ajaxurl, {
|
|
|
|
action: 'set-background-image',
|
|
|
|
attachment_id: id,
|
2020-10-29 14:09:13 -04:00
|
|
|
_ajax_nonce: nonceValue,
|
2012-08-22 20:04:18 -04:00
|
|
|
size: img_size
|
2016-08-20 18:59:29 -04:00
|
|
|
}, function() {
|
2012-08-22 20:04:18 -04:00
|
|
|
var win = window.dialogArguments || opener || parent || top;
|
|
|
|
win.tb_remove();
|
|
|
|
win.location.reload();
|
|
|
|
});
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|