Custom "Upload/Insert" Media Toolbar

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

Many new users to WordPress get confused by the multiple default “Upload / Insert” options. Here is an option to strip down these buttons to your needs.

This snippet replaces the output from “media_buttons_context” (all the “Upload/Insert” buttons) with just what comes after the “return” (in this case, just the image upload).

Simply paste in your functions.php file.

Code Snippet:

<?php
// 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');
?>

Posted in Admin area