X

How To Create a Media Library URL Column for Easy Copying and Pasting

Snippets by IsItWP

Are you looking for a way to create a Media Library URL column? This snippet will create a new column in the Media Library with the file URL that will allow you to easily copy and paste the URL.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

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 );

Thanks to Steve Taylor for the original snippet. Thanks to Jurko Chervony for suggested tweaks.

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 27 best WordPress business themes for your website and 15 best content marketing tools and plugins for WordPress.

Comments   Leave a Reply

  1. Uthain Phromdaeng September 26, 2017 at 10:15 pm

    Wow, Thank you so much.

  2. Julian Kingman March 16, 2015 at 6:28 pm

    Awesome. I was looking for a plugin, but this is way easier and is now rolled into my child theme (and future child themes). Thanks!

  3. Was looking all morning for something like this….Thanks

  4. Oseghale Ibhawoh January 14, 2015 at 6:25 am

    Works perfectly. Many thanks man!

  5. How To Add URL Column To WordPress Media Library? September 10, 2014 at 10:27 pm

    […] Source: http://wpsnipp.com/ […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!