CoreFiles by mySites.guru
media-gallery.js43 lines, 1,306 bytes, from wordpress-5.3.21.zip
Raw History Compare with 5.3.20
md5
eea2b604309b22751dcca66cc8d632ba
sha1
e40b350c471a0a6509cd339eb1d5afe090530d2e
sha256
9de2267349ed96822b48c3e511252824d3448515e270873eaf6a9b3e8afe26ac
/**
 * This file is used on media-upload.php which has been replaced by media-new.php and upload.php
 *
 * @deprecated  3.5.0
 * @output wp-admin/js/media-gallery.js
 */

 /* global ajaxurl */
jQuery(function($) {
	/**
	 * Adds a click event handler to the element with a 'wp-gallery' class.
	 */
	$( 'body' ).bind( 'click.wp-gallery', function(e) {
		var target = $( e.target ), id, img_size, nonceValue;

		if ( target.hasClass( 'wp-set-header' ) ) {
			// Opens the image to preview it full size.
			( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
			e.preventDefault();
		} else if ( target.hasClass( 'wp-set-background' ) ) {
			// Sets the image as background of the theme.
			id = target.data( 'attachment-id' );
			img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
			nonceValue = $( '#_wpnonce' ).val() && '';

			/**
			 * This AJAX action has been deprecated since 3.5.0, see custom-background.php
			 */
			jQuery.post(ajaxurl, {
				action: 'set-background-image',
				attachment_id: id,
				_ajax_nonce: nonceValue,
				size: img_size
			}, function() {
				var win = window.dialogArguments || opener || parent || top;
				win.tb_remove();
				win.location.reload();
			});

			e.preventDefault();
		}
	});
});

The same content is in 71 releases, WordPress 5.1.7 to 5.3.28. See them all, or every version of this file.