You can do this via,
add_filter('image_send_to_editor', 'restrict_images');
function restrict_images($html){
return false;
}
…now consider the above function primitive, because it will restrict images for all post types. We can modify that on a post_type
by post_type
basis like so,
add_filter('image_send_to_editor', 'restrict_images');
function restrict_images($html){
// check if its the admin trying to insert image, if so, quickly
// return the image to the editor and do not run remainder of function
if(current_user_can('activate_plugins'))
return $html;
// global $post and $wp_query not available so we use $_POST['key']
$post_id = $_POST['post_id'];
// with post ID in hand we now get current post_type
$post_type = get_post_type($post_id);
// define list of our restricted post_types
$restricted = array('post', 'page');
// check current post_type against array of restricted post_types
if (in_array($post_type, $restricted)) {
// if our current post_type as returned from get_post_type is in array
// we return false to void inserting image into post editor
return false;
} else {
// if our post_type does not exist in restricted array, carry on as normal
return $html;
}
}