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; }
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
hi, how would you alter this to use
$filename = basename ( get_attached_file( $data->ID ) );
as the download=” xxx ” ?