i’m trying to add image size in media library screen so will be simply to handle images. Anyone does it before me?
Any help appreciated.
Francesco

2 s
2

Code based on Custom Sortable Columns

add_filter('manage_upload_columns', 'size_column_register');

function size_column_register($columns) {

    $columns['dimensions'] = 'Dimensions';

    return $columns;
}

add_action('manage_media_custom_column', 'size_column_display', 10, 2);

function size_column_display($column_name, $post_id) {

    if( 'dimensions' != $column_name || !wp_attachment_is_image($post_id)) return;

    list($url, $width, $height) = wp_get_attachment_image_src($post_id, 'full');

    echo esc_html("{$width}×{$height}");
}

Leave a Reply

Your email address will not be published. Required fields are marked *