Skip to main content

Here you go, this code not only lists all filenames in Library but also allows you to sort them by name:

// Add the column
function filename_column( $cols ) {
        $cols["filename"] = "Filename";
        return $cols;
}

// Display filenames
function filename_value( $column_name, $id ) {
    $meta = wp_get_attachment_metadata( $id );
           echo substr( strrchr( $meta['file'], '/' ), 1); 
          // Used a few PHP functions cause 'file' stores local url to file not filename
}

// Register the column as sortable & sort by name
function filename_column_sortable( $cols ) {
    $cols["filename"] = "name";
 
    return $cols;
}
 

// Hook actions to admin_init
function hook_new_media_columns() {
    add_filter( 'manage_media_columns', 'filename_column' );
    add_action( 'manage_media_custom_column', 'filename_value', 10, 2 );
    add_filter( 'manage_upload_sortable_columns', 'filename_column_sortable' );
}
add_action( 'admin_init', 'hook_new_media_columns' );

Here you go, this code not only lists all filenames in Library but also allows you to sort them by name:

// Add the column
function filename_column( $cols ) {
        $cols["filename"] = "Filename";
        return $cols;
}

// Display filenames
function filename_value( $column_name, $id ) {
    $meta = wp_get_attachment_metadata($id);
           echo substr( strrchr($meta['file'], '/' ), 1); 
          //Used a few PHP functions cause 'file' stores local url to file not filename
}

// Register the column as sortable & sort by name
function filename_column_sortable( $cols ) {
    $cols["filename"] = "name";
 
    return $cols;
}
 

// Hook actions to admin_init
function hook_new_media_columns() {
    add_filter( 'manage_media_columns', 'filename_column' );
    add_action( 'manage_media_custom_column', 'filename_value', 10, 2 );
    add_filter( 'manage_upload_sortable_columns', 'filename_column_sortable' );
}
add_action( 'admin_init', 'hook_new_media_columns' );

Here you go, this code not only lists all filenames in Library but also allows you to sort them by name:

// Add the column
function filename_column( $cols ) {
    $cols["filename"] = "Filename";
    return $cols;
}

// Display filenames
function filename_value( $column_name, $id ) {
    $meta = wp_get_attachment_metadata( $id );
    echo substr( strrchr( $meta['file'], '/' ), 1); 
    // Used a few PHP functions cause 'file' stores local url to file not filename
}

// Register the column as sortable & sort by name
function filename_column_sortable( $cols ) {
    $cols["filename"] = "name";
    return $cols;
}

// Hook actions to admin_init
function hook_new_media_columns() {
    add_filter( 'manage_media_columns', 'filename_column' );
    add_action( 'manage_media_custom_column', 'filename_value', 10, 2 );
    add_filter( 'manage_upload_sortable_columns', 'filename_column_sortable' );
}
add_action( 'admin_init', 'hook_new_media_columns' );
Source Link
Bart Karp
  • 261
  • 1
  • 4

Here you go, this code not only lists all filenames in Library but also allows you to sort them by name:

// Add the column
function filename_column( $cols ) {
        $cols["filename"] = "Filename";
        return $cols;
}

// Display filenames
function filename_value( $column_name, $id ) {
    $meta = wp_get_attachment_metadata($id);
           echo substr( strrchr($meta['file'], '/' ), 1); 
          //Used a few PHP functions cause 'file' stores local url to file not filename
}

// Register the column as sortable & sort by name
function filename_column_sortable( $cols ) {
    $cols["filename"] = "name";

    return $cols;
}


// Hook actions to admin_init
function hook_new_media_columns() {
    add_filter( 'manage_media_columns', 'filename_column' );
    add_action( 'manage_media_custom_column', 'filename_value', 10, 2 );
    add_filter( 'manage_upload_sortable_columns', 'filename_column_sortable' );
}
add_action( 'admin_init', 'hook_new_media_columns' );