Advertisement
jameslafferty

WordPress Image Uploader Custom

Apr 8th, 2011
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function (win, doc, $, undefined) {
  2.     $.fn.wpmediabox = function (options) {
  3.         var $this = $(this),
  4.             defaults = {
  5.                 "type" : "image",
  6.                 "post_id" : 0,
  7.                 "label" : "Use This Image"
  8.             },
  9.             opts = {},
  10.             send_to_editor = (win.send_to_editor) ? win.send_to_editor : undefined;
  11.         opts = $.extend(defaults, options);
  12.         $this.bind('click', function () {
  13.             tbframe_interval = setInterval(function() {
  14.                 $('#TB_iframeContent').contents().find('.savesend .button').val(opts.label);
  15.             }, 2000);
  16.             tb_show('', 'media-upload.php?post_id=' + opts.post_id + '&type=' + opts.type + '&TB_iframe=true');
  17.             return false;
  18.         });
  19.         win.send_to_editor = function (html) { 
  20.             clearInterval(tbframe_interval);
  21.             if (opts.callback) {
  22.                 opts.callback(html);
  23.                 tb_remove();
  24.                
  25.             } else {
  26.                 send_to_editor();
  27.             }
  28.         };
  29.     }
  30. }(window, document, jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement