kollapsminoriteten/wp-admin/js/media-gallery.js

44 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2019-11-02 10:38:58 +01:00
/**
* This file is used on media-upload.php which has been replaced by media-new.php and upload.php
*
2020-05-06 17:23:38 +02:00
* @deprecated 3.5.0
2019-11-02 10:38:58 +01:00
* @output wp-admin/js/media-gallery.js
*/
/* global ajaxurl */
jQuery(function($) {
/**
* Adds a click event handler to the element with a 'wp-gallery' class.
*/
2021-04-27 08:32:47 +02:00
$( 'body' ).on( 'click.wp-gallery', function(e) {
2020-11-18 09:08:48 +01:00
var target = $( e.target ), id, img_size, nonceValue;
2019-11-02 10:38:58 +01:00
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();
2020-11-18 09:08:48 +01:00
nonceValue = $( '#_wpnonce' ).val() && '';
2019-11-02 10:38:58 +01:00
/**
2020-09-15 14:29:22 +02:00
* This Ajax action has been deprecated since 3.5.0, see custom-background.php
2019-11-02 10:38:58 +01:00
*/
jQuery.post(ajaxurl, {
action: 'set-background-image',
attachment_id: id,
2020-11-18 09:08:48 +01:00
_ajax_nonce: nonceValue,
2019-11-02 10:38:58 +01:00
size: img_size
}, function() {
var win = window.dialogArguments || opener || parent || top;
win.tb_remove();
win.location.reload();
});
e.preventDefault();
}
});
});