Easier Access to Media File from Media Library

Maybe it’s just me, but sometimes I’d link to grab an image’s file URL from the Media Library, but I can’t do it easily. This little snippet will add a link to the ‘row actions’ (“Edit | Delete Permanently | View”) for the File URL (as opposed the the attachment URL you’ll get with the ‘view’ link)

add_filter ('media_row_actions','add_direct_link', 10, 3 );
function add_direct_link( $actions, $post, $detached ) {
	$actions['file_url'] = '<a href="' . wp_get_attachment_url($post->ID) . '">Actual File</a>';
	return $actions;
}

2 thoughts on “Easier Access to Media File from Media Library”

  1. Joseph Barrett

    Hi, thanks for this! I added download=”‘ . wp_get_attachment_url($post->ID) . ‘” target=”_blank” to the filter so we can download with one click! thanks so much

  2. Joseph Barrett

    hi, how would you alter this to use
    $filename = basename ( get_attached_file( $data->ID ) );
    as the download=” xxx ” ?

Leave a Reply

Your email address will not be published. Required fields are marked *