Make WordPress Core

Opened 2 years ago

Last modified 3 months ago

#60549 assigned enhancement

"Site Upload Quota Space" should indicate network default and possibly site's current usage

Reported by: madtownlems's profile MadtownLems Owned by: realloc's profile realloc
Milestone: 7.0 Priority: normal
Severity: normal Version:
Component: Networks and Sites Keywords: has-test-info needs-design-feedback changes-requested
Focuses: multisite Cc:

Description

In Multisite, there is a network default site quota which can be overridden on individual sites by visiting /wp-admin/network/site-settings.php?id=BLOG_ID

It says:
Site Upload Space Quota (input box here) MB (Leave blank for network default).

It would be incredibly helpful to have easy access to two other pieces of information here.

1) The network default.

This could be shown as: (Leave blank for network default: 2500 MB)

2) The site's current use.

This could be shown as. (Leave blank for network default: 2500 MB) (Space currently used: 100 MB)

Each of these pieces of information would really help in editing sites to change the storage quota. I'd suggest the network default is more important, and if only one were to be added, that should be it.

Change History (26)

This ticket was mentioned in PR #8303 on WordPress/wordpress-develop by @lenasterg.


11 months ago
#1

  • Keywords has-patch added

This pull request fixes the issues descripted in the ticket Trac ticket: [](https://core.trac.wordpress.org/ticket/60549)
In superadmin 'Edit site' page:

  1. Shows the network default Site upload space
  2. The site's current use.

and also displays space usage information to the sub site administration in the media gallery pages.

This update introduces a new function, get_space_usage(), which enhances the way WordPress reports upload space usage for a site. The function calculates the space used for uploads and provides a detailed or simplified report based on whether the upload space check is enabled or disabled.

When upload space check is disabled: The function returns a simple message showing the space used in megabytes (e.g., "500 MB Space Used").

When upload space check is enabled: The function provides a more detailed report, including the percentage of space used and the total space allowed (e.g., "Used: 500 MB (50%) of 1 GB").

This enhancement improves transparency and usability for site administrators by offering clearer insights into their site's storage usage. The function also uses localization-friendly strings, ensuring compatibility with multilingual setups.

Technical Details:

The function get_space_usage() leverages existing helper functions like get_space_used(), get_space_allowed(), and size_format() to calculate and format the space usage.

The function respects the upload_space_check_disabled site option to determine the level of detail in the output.

This change is backward-compatible and does not affect existing functionality. It is particularly useful for multisite networks where storage management is critical.
The following images show the visual changes to the various pages.

In "Edit site"
https://github.com/user-attachments/assets/4782ed2f-5787-4379-80cd-57f78b0be02e

In 'Dashboard'
Before the suggested changes, when the upload_space_check_disabled site option was enabled, the admin had no information about the storage space.
https://github.com/user-attachments/assets/db033a5c-a9c2-449c-9e9e-ff14ddf612ed
After the suggested changes:
https://github.com/user-attachments/assets/9e53e26d-ce9a-487b-8749-4e79f753d0af
https://github.com/user-attachments/assets/3e8a0303-5818-4d94-9259-cbed68462b61

In 'Media Gallery'
https://github.com/user-attachments/assets/4b9ac166-6141-4caf-9519-60c58ec85965
https://github.com/user-attachments/assets/9af3f306-d15e-43d6-a76c-a8e0901b94bc

In media upload pages
https://github.com/user-attachments/assets/24e82ec6-1b51-4255-8c84-eb6204132d22
https://github.com/user-attachments/assets/c51b5b40-4b18-4201-b9c5-169bdafb2d47
https://github.com/user-attachments/assets/4c80fe11-50a0-4367-af37-a229991f06bf

This ticket was mentioned in Slack in #core-multisite by lenasterg. View the logs.


11 months ago

This ticket was mentioned in Slack in #core by lenasterg. View the logs.


11 months ago

#4 @joemcgill
11 months ago

  • Milestone changed from Awaiting Review to 6.8

Adding to the 6.8 milestone for visibility.

#5 follow-up: @MadtownLems
11 months ago

I like all of these inclusions except the one at the top of the Media Library. Users already complain frequently about too many notices at the top of their admin screens; I don't think we should contribute to that problem. Thank you for putting this together!

#6 in reply to: ↑ 5 @lenasterg
11 months ago

Replying to MadtownLems:

I like all of these inclusions except the one at the top of the Media Library. Users already complain frequently about too many notices at the top of their admin screens; I don't think we should contribute to that problem. Thank you for putting this together!

Hi.
I understand the concern about notices at the top of the Media Library. However, it’s placed where users expect to find storage-related information, making it easier to manage upload space without having to navigate elsewhere. I believe it provides value by being contextually relevant rather than disruptive.

@audrasjb commented on PR #8303:


11 months ago
#7

I added some commits to fix a handful of WPCS issues.

@audrasjb commented on PR #8303:


11 months ago
#8

Phew, all the coding standard issues are now fixed 😅

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


11 months ago

#10 @audrasjb
11 months ago

  • Keywords needs-testing added
  • Milestone changed from 6.8 to 6.9

As per today's bug scrub: It appears this ticket is still needs user testing. As 6.8 beta 1 is very close, I'm moving it to 6.9. Feel free to move it back to 6.8 if it can be committed by Monday.

#11 follow-up: @MadtownLems
11 months ago

I understand the concern about notices at the top of the Media Library. However, it’s placed where users expect to find storage-related information, making it easier to manage upload space without having to navigate elsewhere. I believe it provides value by being contextually relevant rather than disruptive.

My suggestion is to only display it here when the quota is approaching full. There's little value in mentioning the space quota if they're using, say, 5% of it. I would definitely argue that's it's disruptive, rather than helpful, in that case. Perhaps if it was only displayed when it's becoming a concern; something like when 90% or more of the site's storage space is used.

#12 in reply to: ↑ 11 @lenasterg
11 months ago

Hi.

If I understand correctly, your only concern is that it appears as a notice in the Media Gallery.
This is easy to change in the proposed patch.

Would you agree if I remove the following from the proposed patch?

add_action( 'load-upload.php', 'upload_page_notice_display_space_usage_notice' );

https://github.com/WordPress/wordpress-develop/blob/140d05bdce4ee58aeffabe3ef41d11041bfed248/src/wp-admin/includes/ms-admin-filters.php#L13

Along with the related functions:

  • upload_page_notice_display_space_usage_notice()
  • display_space_usage_notice()

https://github.com/WordPress/wordpress-develop/blob/140d05bdce4ee58aeffabe3ef41d11041bfed248/src/wp-admin/includes/ms.php#L281

What do you think, about it?

Replying to MadtownLems:

I understand the concern about notices at the top of the Media Library. However, it’s placed where users expect to find storage-related information, making it easier to manage upload space without having to navigate elsewhere. I believe it provides value by being contextually relevant rather than disruptive.

My suggestion is to only display it here when the quota is approaching full. There's little value in mentioning the space quota if they're using, say, 5% of it. I would definitely argue that's it's disruptive, rather than helpful, in that case. Perhaps if it was only displayed when it's becoming a concern; something like when 90% or more of the site's storage space is used.

#13 follow-up: @SirLouen
9 months ago

  • Keywords has-testing-info changes-requested added; has-patch needs-testing removed

Patch Test Report

Description

❌ This report can't fully validate that the indicated patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/8303.diff

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 135.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Fifteen 4.0
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.0

Patch Testing Reproduction Steps

  1. Here are the places where the content should be seen:
  • /wp-admin/network/site-settings.php?id=<blog_id>
  • /wp-admin/ ⇒ Individual Site Dashboard > At a Glance Widget
  • /wp-admin/upload.php ⇒ As a Notice
  • /wp-admin/upload.php ⇒ Inside Media > Add Media File button
  • /wp-admin/media-new.php
  1. Check Network Settings > Site upload space

Expected Results

  • Used Space, and, remaining space should be displayed in all 5 areas

Actual Results

  • ✅ The text can be seen in all these 5 areas
  • ✅ If the Site Site upload space is checked and filled, it displays the right information in all areas
  • ❌ If the Site Site upload space is checked but not filled there is an issue, check notes

Additional Notes

  1. The only error I've found is that when Site upload space is not filled, it doesn't display default 100 MB in this section:

https://i.imgur.com/S2u44uK.png

  1. Regarding this suggestion I have provided some ideas within the PR 8303

This ticket was mentioned in Slack in #core-multisite by lenasterg. View the logs.


9 months ago

#15 @wordpressdotorg
8 months ago

  • Keywords has-test-info added; has-testing-info removed

This ticket was mentioned in Slack in #core-multisite by lenasterg. View the logs.


8 months ago

#17 in reply to: ↑ 13 @ideag
8 months ago

  • ❌ If the Site Site upload space is checked but not filled there is an issue, check notes

This was fixed with the latest commit - it now respects and shows the default value for the option

#18 @SirLouen
7 months ago

  • Keywords needs-design-feedback added; changes-requested removed

Design Feedback Needed

@ideag now everything is working, but I believe, as many others have stated, that the notice is too much in wp-admin/upload.php

Personally, I would opt to remove it or, at best, just add that notice when it drops under certain fixed % (say for example 10%), configurable via filter hook.

#19 follow-up: @realloc
7 months ago

  • Keywords changes-requested added
  • Owner set to realloc
  • Status changed from new to assigned

Thanks everyone for the great work on this enhancement. It’s a very helpful addition for multisite administrators.

I’d also like to suggest going the last few meters and refining the Media Library notice:

Instead of always displaying it, it could appear only when a defined threshold is reached. This would keep the interface clean for most users while still drawing attention when action is needed.

#20 in reply to: ↑ 19 @lenasterg
5 months ago

Hi.

Thanks for the positive feedback and the thoughtful suggestion!

I’d suggest displaying the notice only when a site’s available upload space drops below 25% of its total quota. This way, users receive a warning only when it’s truly relevant, avoiding unnecessary clutter for those who still have plenty of space.

A suggestion to do it by using the built-in get_space_used() and get_space_allowed() functions. To make the notice as unobtrusive as possible, it should be shown only on the Media Library admin page (upload.php) and only for subsites, not the main site.

A suggestion to do it:


/**
 * Display a warning notice in the Media Library admin page
 * when the available upload space is less than 25% of the total quota.
 *
 * Applies only to subsites in a WordPress Multisite installation.
 */
add_action('admin_notices', 'custom_disk_space_warning');

function custom_disk_space_warning() {
    global $pagenow;

    // Only show notice on the Media Library page
    if ($pagenow !== 'upload.php') {
        return;
    }

    // Skip the main site (usually has no quota restrictions)
    if (!is_main_site()) {
        /**
         * Get the total and used upload space for the current site.
         * Both values are in megabytes (MB).
         */
        $space_allowed = get_space_allowed(); // Total quota (MB)
        $space_used    = get_space_used();    // Used space (MB)

        // Ensure quota is set and check if usage exceeds 75%
        if ($space_allowed > 0 && ($space_used / $space_allowed) >= 0.75) {
            // Display warning notice if remaining space is below 25%
            echo '<div class="notice notice-warning"><p><strong>Warning:</strong> You have used more than 75% of your available upload space.</p></div>';
        }
    }
}

This implementation ensures that the warning is shown only when needed, and only in the appropriate context, providing a better and less intrusive experience for multisite administrators.

Thanks again for raising this—refinements like these really help improve usability at scale.

Replying to realloc:

Thanks everyone for the great work on this enhancement. It’s a very helpful addition for multisite administrators.

I’d also like to suggest going the last few meters and refining the Media Library notice:

Instead of always displaying it, it could appear only when a defined threshold is reached. This would keep the interface clean for most users while still drawing attention when action is needed.

#21 follow-up: @realloc
5 months ago

@lenasterg Did you add this to your PR?

#22 in reply to: ↑ 21 @lenasterg
5 months ago

No, I'm still in holidays without laptop.
If you want and have time please do so.

Replying to realloc:

@lenasterg Did you add this to your PR?

This ticket was mentioned in Slack in #core by welcher. View the logs.


4 months ago

This ticket was mentioned in Slack in #core by welcher. View the logs.


3 months ago

#25 @welcher
3 months ago

  • Milestone changed from 6.9 to 7.0

#26 @welcher
3 months ago

Tomorrow is 6.9 Beta 1 and there hasn't been any movement so I'm going to punt it to 7.0

Note: See TracTickets for help on using tickets.