Created
July 26, 2022 22:24
-
-
Save kwcjr/7ccb956346e924ca8d03819f75d8ea9d to your computer and use it in GitHub Desktop.
List wp /upload directory file sizes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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