Displaying individual image size URLs in the Media Library

Hi, Abdul was helping me but we got cut off. He sent over some PHP that I put into my functions.php in order to display image sizes URLs in the Media Library, but it didn't work and he asked for the SFTP login. I'm ready with that whenever you are.

  • Predrag Dubajic
    • Support

    Hi Gabriel,

    Seems like the code he shared was missing some lines, perhaps he didn't copy it properly :slight_smile:
    Can you try using this and see if that does the trick for you:

    function wpse_237131_add_column_file_size( $columns ) { // Create the column
    	$columns['filesize'] = 'File Size';
    	return $columns;
    add_filter( 'manage_media_columns', 'wpse_237131_add_column_file_size' );
    function wpse_237131_column_file_size( $column_name, $media_item ) { // Display the file size
    	if ( 'filesize' != $column_name || !wp_attachment_is_image( $media_item ) ) {
    	//$filesize = filesize( get_attached_file( $media_item ) );
    	//$filesize = size_format($filesize, 2);
    	//echo $filesize;
    	$up_load_dir = wp_upload_dir();
    	$dir = $up_load_dir['url'];
    	// Get the info for each media item
    	$meta = wp_get_attachment_metadata($media_item);
    	// and loop + output
    	foreach ( $meta['sizes'] as $name=>$info) {
    	// could limit which sizes are output here with a simple if $name ==
    		echo "<strong>" . $name . "</strong><br>";
    		echo "<small>" . $dir . "/" . $info['file'] . " </small><br>";
    add_filter( 'manage_media_custom_column', 'wpse_237131_column_file_size', 10, 2 );

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.