No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

62 líneas
1.5 KiB

  1. /* global isRtl */
  2. (function($) {
  3. var frame;
  4. $( function() {
  5. // Fetch available headers and apply jQuery.masonry
  6. // once the images have loaded.
  7. var $headers = $('.available-headers');
  8. $headers.imagesLoaded( function() {
  9. $headers.masonry({
  10. itemSelector: '.default-header',
  11. isRTL: !! ( 'undefined' != typeof isRtl && isRtl )
  12. });
  13. });
  14. // Build the choose from library frame.
  15. $('#choose-from-library-link').click( function( event ) {
  16. var $el = $(this);
  17. event.preventDefault();
  18. // If the media frame already exists, reopen it.
  19. if ( frame ) {
  20. frame.open();
  21. return;
  22. }
  23. // Create the media frame.
  24. frame = wp.media.frames.customHeader = wp.media({
  25. // Set the title of the modal.
  26. title: $el.data('choose'),
  27. // Tell the modal to show only images.
  28. library: {
  29. type: 'image'
  30. },
  31. // Customize the submit button.
  32. button: {
  33. // Set the text of the button.
  34. text: $el.data('update'),
  35. // Tell the button not to close the modal, since we're
  36. // going to refresh the page when the image is selected.
  37. close: false
  38. }
  39. });
  40. // When an image is selected, run a callback.
  41. frame.on( 'select', function() {
  42. // Grab the selected attachment.
  43. var attachment = frame.state().get('selection').first(),
  44. link = $el.data('updateLink');
  45. // Tell the browser to navigate to the crop step.
  46. window.location = link + '&file=' + attachment.id;
  47. });
  48. frame.open();
  49. });
  50. });
  51. }(jQuery));