1878 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 :)

1036 posts It's in the pipeline!
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
  • Elite Author: Sold more than $75,000 on Envato Market
  • 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 4 years
  • Sells items exclusively on Envato Market
FirestormGraphics says

cheers booby :delicious:

1645 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 ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by