X

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.


Thanks to Jurko Chervony for the suggested tweaks.

Code Snippet:


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

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/ […]

  6. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  7. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  8. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  9. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  10. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  11. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  12. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  13. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  14. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  15. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  16. Thank you so much for sharing this. You just saved me a couple of hours and a bottle of Advil.

  17. Thank you so much for this. Made a nifty little plugin for this!

  18. Thank you so much for this. Made a nifty little plugin for this!

  19. I copied and pasted it at the very bottom of the ‘functions.php’ file, and when I tried to open the website again, it gave me a fatal error. Any ideas why? I’m using wordpress 3.8.

    1. Without taking a look at your functions.php I would not be sure what the issue was. You could put it on pastebin.com and use the contact form to send me the link so i can take a look at it.

      http://wpsnipp.com/index.php/contact/

  20. Hi Brent,

    This may be good for some, just not sure its a great feature for everyone. Thanks for the feedback its great to hear what I’m posting is helping people.

  21. man this is awesome! why this isn’t default in wordpress who knows. thanks a million!

  22. Awesome! Thanks.

  23. Thank you, thank you, thank you. I was going crazy with all the drilling down for urls. I really appreciate it!

  24. So convenient. This should be a plugin… that gives me an idea!

  25. oh maaaan you are the BOSSSS!!! Thanks!

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!