This Q&A shows how to limit the posts a user role is able to see in the dashboard. It was missing the attachments part, which is this:
add_filter( 'pre_get_posts', 'wpse_72278_current_author_media' );
add_filter( 'views_upload', 'wpse_72278_custom_view_count', 10, 1 );
function wpse_72278_current_author_media( $query )
{
global $pagenow, $user_ID;
if( 'upload.php' !== $pagenow )
return $query;
if ( $query->is_admin && current_user_can( 'editor' ) )
$query->set( 'author', $user_ID );
return $query;
}
function wpse_72278_custom_view_count( $views )
{
global $user_ID, $wpdb;
if ( !current_user_can('editor') )
return $views;
$total = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts
WHERE post_author = '$user_ID'
AND post_type = 'attachment' " );
$image = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts
WHERE post_author = '$user_ID'
AND post_mime_type LIKE 'image/%' " );
$video = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts
WHERE post_author = '$user_ID'
AND post_mime_type LIKE 'video/%' " );
$detached = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts
WHERE post_author = '$user_ID'
AND post_type = 'attachment' AND post_parent = '0' " );
$views['all'] = preg_replace( '/\(.+\)/U', '('.$total.')', $views['all'] );
$views['image'] = preg_replace( '/\(.+\)/U', '('.$image.')', $views['image'] );
$views['video'] = preg_replace( '/\(.+\)/U', '('.$video.')', $views['video'] );
$views['detached'] = preg_replace( '/\(.+\)/U', '('.$detached.')', $views['detached'] );
return $views;
}
This other takes care of the issue of a post owned by one author and the upload made by another.
And case you're not jumping into 3.5 yet, this last one handles Custom Fields for Attachments.