1840 posts YOU TOUCH IT YOU BUY IT
  • Bought between 100 and 499 items
  • Referred between 200 and 499 users
  • Has been a member for 4-5 years
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
+1 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
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • United Kingdom
m1chelangel0 says

Thank you kind Sir :)

964 posts It's in the pipeline!
  • Elite Author
  • Has been a member for 5-6 years
  • Bought between 100 and 499 items
  • Referred between 200 and 499 users
  • Exclusive Author
  • Microlancer Beta Tester
  • Author had a Free File of the Month
+2 more
purethemes says

boobslover :D

FirestormGraphics
FirestormGraphics Recent Posts
Threads Started
38 posts
  • United Kingdom
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Exclusive Author
FirestormGraphics says

cheers booby :delicious:

1437 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Microlancer Beta Tester
webdesignerart says

boobslover :D

WHAT :P

701 posts
  • Bought between 1000 and 4999 items
  • Canada
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
chrismccoy says

love the github username ;)

by
by
by
by
by
by