Download Link for Media Files

This functionality is provided by certain plugins, and others let you download your whole media library. But what if all you want to do is download a single file?

In that case, simply open the URL in a new tab without copying it.

What we want is a Download File link row action for a one-click-download. This snippet will do just that, allowing you to download whatever file it is directly to your computer.

add_filter( 'media_row_actions','weszty_web_media_file_download_link', 10, 3 );
function weszty_web_media_file_download_link( $actions, $post, $detached ) {
    $actions['file_url'] = '<a href="' . wp_get_attachment_url( $post->ID ) . '" download="' . wp_get_attachment_url( $post->ID ) . '" target="_blank">Download File</a>';
    return $actions;

Don't be weird.

Would you like more information or do you have a question?

Drag View Close play