Media library URL column for easy copy and paste

Add this snippet to the functions.php of your wordpress theme to create a new column with the original file URL. I have had a few projects in the past that required a client to copy and paste a files URL into a custom field or metabox this will just make life a little easier. Thanks to Steve Taylor for this snippet, I just expanded on it a little with the input field and onclick select.

 

function muc_column( $cols ) {
$cols["media_url"] = "URL";
return $cols;
}
function muc_value( $column_name, $id ) {
if ( $column_name == "media_url" ) echo '<input type="text" width="100%" onclick="jQuery(this).select();" value="'. wp_get_attachment_url( $id ). '" />';
}
add_filter( 'manage_media_columns', 'muc_column' );
add_action( 'manage_media_custom_column', 'muc_value', 10, 2 );

Be Sociable, Share!

Leave a comment