How To Add URL Column To WordPress Media Library?

Sometimes, When you want to copy the URL of an image or a file stored in WordPress media library, first you have to edit that that specific file and then you are able to copy the URL from ready only input box know as “File URL” on Edit Media page.

How To Add URL Column To WordPress Media Library on the Dashboard?

In this post, I will show you how you can add a URL column to media library which will make it easier to copy and paste URL of a specific file.

//Add URL Column to media library
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 );

Useful Read: How to disable login form shake effect from WordPress

Source: http://wpsnipp.com/

0 Comments

Leave a Comment.