media-gallery.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * This file is used on media-upload.php which has been replaced by media-new.php and upload.php
  3. *
  4. * @deprecated 3.5.0
  5. * @output wp-admin/js/media-gallery.js
  6. */
  7. /* global ajaxurl */
  8. jQuery(function($) {
  9. /**
  10. * Adds a click event handler to the element with a 'wp-gallery' class.
  11. */
  12. $( 'body' ).bind( 'click.wp-gallery', function(e) {
  13. var target = $( e.target ), id, img_size;
  14. if ( target.hasClass( 'wp-set-header' ) ) {
  15. // Opens the image to preview it full size.
  16. ( window.dialogArguments || opener || parent || top ).location.href = target.data( 'location' );
  17. e.preventDefault();
  18. } else if ( target.hasClass( 'wp-set-background' ) ) {
  19. // Sets the image as background of the theme.
  20. id = target.data( 'attachment-id' );
  21. img_size = $( 'input[name="attachments[' + id + '][image-size]"]:checked').val();
  22. /**
  23. * This AJAX action has been deprecated since 3.5.0, see custom-background.php
  24. */
  25. jQuery.post(ajaxurl, {
  26. action: 'set-background-image',
  27. attachment_id: id,
  28. size: img_size
  29. }, function() {
  30. var win = window.dialogArguments || opener || parent || top;
  31. win.tb_remove();
  32. win.location.reload();
  33. });
  34. e.preventDefault();
  35. }
  36. });
  37. });