Update on February 12, 2017: Created a Plugin version of this. See near the end of this post.
Wouldn’t it be handy to be able to easily copy a media item URL directly on the main Media Library screen rather than having to open the item?
The following is better formatted version of this code and adds a URL column in the media library. Clicking inside a URL field selects the URL ready for you to copy.
add_filter( 'manage_media_columns', 'sk_media_columns_url' );
/**
* Filter the Media list table columns to add a URL column.
*
* @param array $posts_columns Existing array of columns displayed in the Media list table.
* @return array Amended array of columns to be displayed in the Media list table.
*/
function sk_media_columns_url( $posts_columns ) {
$posts_columns['media_url'] = 'URL';
return $posts_columns;
}
add_action( 'manage_media_custom_column', 'sk_media_custom_column_url' );
/**
* Display URL custom column in the Media list table.
*
* @param string $column_name Name of the custom column.
*/
function sk_media_custom_column_url( $column_name ) {
if ( 'media_url' !== $column_name ) {
return;
}
echo '<input type="text" width="100%" onclick="jQuery(this).select();" value="' . wp_get_attachment_url() . '" />';
}
add_action( 'admin_print_styles-upload.php', 'sk_url_column_css' );
/**
* Add custom CSS on Media Library page in WP admin
*/
function sk_url_column_css() {
echo '<style>
@media only screen and (min-width: 1400px) {
.fixed .column-media_url {
width: 15%;
}
}
</style>';
}
Goes in child theme’s functions.php.
Plugin
If you would like to use a plugin for this functionality, get it from here: https://github.com/srikat/URL-Admin-Column.
Reference: https://sridharkatakam.com/add-time-admin-column-wordpress-media-library/
What would you change in this if you just wanted to see the file size? When I’m doing speed optimizations, I typically look via FTP to make sure there aren’t any image size violators, but in this dashboard would be really convenient too.
Do you want File Size column in addition to URL’s or instead of it?
Here you go: https://sridharkatakam.com/add-file-size-admin-column-wordpress-media-library/
Absolutely brilliant !
Hi Sridhar,
I’d like to use this code to output a list of all urls in the media library – to a web page or a file so I can use the list in an excel file – don’t have much experience with php. What would be the simplest way to do this?
Thanks for any help
Hi David,
Try https://wordpress.org/plugins/wp-all-export/.