Can’t edit media details in new role

As mentioned in my comment(s), below the code as it imho should be.(tested and working)

/**
 * Add new role: Writer
 * This role allows to: Add/Edit/Delete Posts and Uploads
 *
 * Read more: {@link https://codex.wordpress.org/Roles_and_Capabilities}
 *
 * Works with @version WP4.8.1 and below
 */
add_role( 'writer', 'Writer', 
    array( 
        'delete_posts'           => true,
        'delete_published_posts' => true,
        'edit_posts'             => true,
        'edit_published_posts'   => true,
        'publish_posts'          => true,
        'read'                   => true,
        'upload_files'           => true, 
        )
    );

Add the code in functions.php and please remove it after it is added/visible in the Back-end(Admin panel) because it will be add to your database. Else WP will try to add the role (although already done) every visit from every user all the time. (Useless and a bad habit in this case)

Just as note, please read the Codex so you understand what I tried to explain.
Adjust (delete unneeded code) to your own preferences.