1872 posts YOU TOUCH IT YOU BUY IT
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
FRESHFACE says

Hi Guys, so today I wrote a simple plugin, which allows you to easily invoke and use the built in WP Media Uploader to upload / select images across all your custom admin pages. The whole code you have to write are 2 lines :)

1.) Create a upload hyperlink

<a href="'.get_bloginfo('wpurl').'/wp-admin/media-upload.php?TB_iframe=1" media-upload-link="slide-1" class="thickbox">Upload / Insert</a>

You see the “media-upload-link” attribute ? It’s important for identify the invoker of the dialog. For example if you have 10 slides, you will create 10 hyperlinks and fill the attribute with slide-1 to slide-10 :)

2.) Add this javascript
$('.thickbox').attachMediaUploader('media-upload-link', function(url, clicked_link_attr_value ){ 
$('sliders').find(clicked_link_attr_value).find('input').attr('value', url);
});

so, the callback function get: url -> of the selected image ( can be new uploaded ) clicked_link_attr_value -> value of attribute of the Original invoker (in this example will be “slide-1”);

of course you will have to include jquery and thickbox for your admin pages:
wp_enqueue_script('jquery');
wp_enqueue_script('thickbox',null,array('jquery'));
wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0');
The plugin can be found here : https://github.com/boobslover/wpmediainvoker
63 posts
  • Has been part of the Envato Community for over 5 years
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
  • Located in United Kingdom
m1chelangel0 says

Thank you kind Sir :)

1004 posts It's in the pipeline!
  • Has sold $500,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 5 years
  • Sells items exclusively on Envato Market
+7 more
purethemes says

boobslover :D

FirestormGraphics
FirestormGraphics Recent Posts Threads Started
38 posts
  • Has collected 1+ items on Envato Market
  • Located in United Kingdom
  • Has been part of the Envato Community for over 3 years
  • Sells items exclusively on Envato Market
FirestormGraphics says

cheers booby :delicious:

1556 posts
  • Has been part of the Envato Community for over 3 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
webdesignerart says

boobslover :D

WHAT :P

701 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Located in Canada
  • Has collected more than 1000 items on Envato Market
chrismccoy says

love the github username ;)

by
by
by
by
by
by