Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a built-in filter to add a custom icon and function to the WordPress "Uploads/Insert" toolbar? This is the toolbar that's located just above the content editor. The existing icon I want to replicate is shown in the blue circle of the image below.

I'd like to add a custom icon that loads the "Add an Image" wizard and passes a special parameter to the upload function such that the attached images get a special meta attribute they would not ordinarily get when uploaded via the standard icon.

The editor toolbar showing the location of the menu I'm interested in adding to

Update: With the help of tnorthcutt's answer below, I've managed to hook into the media icon filter. From here, I should be able to attach a jQuery click event to the image or href and trigger the opening of the media-upload.php, passing a parameter to process the uploads as special...

//Upload custom images
function addMediaIcon($initcontext)
{
    return $initcontext.
   ' <a id="myID" 
      href="javascript:;" 
      onmousedown="return false;" 
      onclick="return false;" 
      title="tooltip">
     <img 
      src="wp-admin/images/media-button-image.gif" 
      onclick="javascript:alert()" title="" />
    </a>';
}
add_filter('media_buttons_context', 'addMediaIcon');
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I'm inclined to say that this is possible. For instance, the Gravity Forms plugin adds an image here. Start with looking at the media_buttons_context hook.

share|improve this answer
    
yep, that's the one. I'm looking at a few examples now > wordpress.org/support/topic/… –  Scott B Nov 18 '10 at 20:30
    
It's definately possible, the polls plugin on wordpress.com blogs does just that...of course i can't speak of implementation right now, but it's definately possible is all i'm saying..... ;) –  t31os Nov 18 '10 at 22:36
add comment

You can also find a good example of using the media_buttons_context filter on the following page. http://www.morgadinho.org/2009/10/16/wordpress-media-buttons/

I know this probably covers what you have already, but wanted to share the link all the same... ;)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.