Advertisement
Guest User

WPAlchemy Media Button Script

a guest
Apr 15th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($){
  2.   $('.upload-button').click(function(e) {
  3.     var button = $(this);
  4.     var input = button.siblings('input:text').first();
  5.     var frame = wp.media( {
  6.         title       : button.data( 'uploader_title' ),
  7.         multiple    : false,
  8.         library     : { type : button.data( 'limit_type' )},
  9.         button      : { text : button.data( 'uploader_button_text' ) }
  10.     } );
  11.  
  12.     frame.on( 'select', function() {
  13.         var attachment = frame.state().get( 'selection' ).first().toJSON();
  14.         $(input).val(attachment.url);
  15.     } );
  16.  
  17.     frame.open();
  18.     return false;
  19.   });
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement