Add extra column in WordPress Media Library

WordPress is one of the most popular blogging platform, It allow you to easily extend the core functionality using Plugins, Themes and Widgets.We have write a small code snippet that will add extra column in WordPress Media Library with image width and height.
You can add this code snippet to the function.php of wordpress theme or can be used as a plugin.

 <?php
function my_column( $cols ) {
	$cols["dimensions"] = "Dimensions (width, height)";
	return $cols;
}
function my_value( $column_name, $id ) {
    $meta = wp_get_attachment_metadata($id);
           if(isset($meta['width']))
           echo $meta['width'].' x '.$meta['height'];
}
add_filter( 'manage_media_columns', 'my_column' );
add_action( 'manage_media_custom_column', 'my_value', 10, 2 );
?>

OR create a file name example.php and put the following code in the newly created file and upload it to the wordpress plugins folder That’s it Now go to wordpress admin and activate it .

 <?php
/*
Plugin Name: Your Plugin Name
Plugin URI:
Description: .
Version: 1.0
Author: Author Name
Author URI: http://authorurl.in
*/
function my_column( $cols ) {
	$cols["dimensions"] = "Dimensions (width, height)";
	return $cols;
}
function my_value( $column_name, $id ) {
    $meta = wp_get_attachment_metadata($id);
           if(isset($meta['width']))
           echo $meta['width'].' x '.$meta['height'];
}
add_filter( 'manage_media_columns', 'my_column' );
add_action( 'manage_media_custom_column', 'my_value', 10, 2 );
?>

Output

plugins Add extra column in WordPress Media Library

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.