Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.