summaryrefslogtreecommitdiffstats
path: root/wp-admin/js/media-gallery.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:56:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:56:49 +0000
commita415c29efee45520ae252d2aa28f1083a521cd7b (patch)
treef4ade4b6668ecc0765de7e1424f7c1427ad433ff /wp-admin/js/media-gallery.js
parentInitial commit. (diff)
downloadwordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.tar.xz
wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.zip
Adding upstream version 6.4.3+dfsg1.upstream/6.4.3+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-admin/js/media-gallery.js')
-rw-r--r--wp-admin/js/media-gallery.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/wp-admin/js/media-gallery.js b/wp-admin/js/media-gallery.js
new file mode 100644
index 0000000..6df4c37
--- /dev/null
+++ b/wp-admin/js/media-gallery.js
@@ -0,0 +1,43 @@
+/**
+ * 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' ).on( '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();
+ }
+ });
+});