Skip to content

Instantly share code, notes, and snippets.

@kwcjr
Created July 26, 2022 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwcjr/7ccb956346e924ca8d03819f75d8ea9d to your computer and use it in GitHub Desktop.
Save kwcjr/7ccb956346e924ca8d03819f75d8ea9d to your computer and use it in GitHub Desktop.
List wp /upload directory file sizes.
$upload_dir = wp_upload_dir();
$folder = $upload_dir['basedir'];
$files = list_files( $folder );
foreach ( $files as $file ) {
if ( is_file( $file ) ) {
$filesize = size_format( filesize( $file ) );
$filename = basename( $file );
echo esc_html( $filename . " - (" . $filesize ) . ")<br />";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment