X

How to Custom “Upload/Insert” Media Toolbar in WordPress

Snippets by IsItWP

Are you looking for a way to custom “upload/insert” media toolbar? While there’s probably a plugin for this, we have created a quick code snippet that you can use to custom “upload/insert” media toolbar in WordPress.

Since WordPress 3.3, there’s only one button in the media toolbar. This is for older versions of WordPress.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

// Custom media buttons
function zg_post_buttons()
	{
	global $post_ID, $temp_ID;
	$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
	$generic_title = 'Upload/Insert';
	$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
	$media_title = 'Add Media';
	$media_button = '<a href="' . $media_upload_iframe_src . '&TB_iframe=true" id="add_media" class="thickbox" title="' . $media_title . '" onclick="return false;"><img src="images/media-button-other.gif" alt="' . $media_title . '" /></a>';
	$video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video");
	$video_title = 'Add Video';
	$video_button = '<a href="' . $video_upload_iframe_src . '&TB_iframe=true" id="add_video" class="thickbox" title="' . $video_title . '" onclick="return false;"><img src="images/media-button-video.gif" alt="' . $video_title . '" /></a>';
	$audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio");
	$audio_title = 'Add Audio';
	$audio_button = '<a href="' . $audio_upload_iframe_src . '&TB_iframe=true" id="add_audio" class="thickbox" title="' . $audio_title . '" onclick="return false;"><img src="images/media-button-music.gif" alt="' . $audio_title . '" /></a>';
	$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image");
	$image_title = 'Afbeeldingen uploaden';
	$image_button = '<a href="' . $image_upload_iframe_src . '&TB_iframe=true" id="add_image" class="thickbox" title="' . $image_title . '" onclick="return false;"><img src="images/media-button-image.gif" alt="' . $image_title . '" /></a>';
	// add/remove values here
	return $media_title . ':' . $media_button;
	}
add_action('media_buttons_context','zg_post_buttons');

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 62 best free WordPress blog themes and how to start a blog.

Comments   Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!