Opened 6 years ago
Last modified 35 hours ago
#51190 reviewing defect (bug)
The display of the Media Uploads settings section should be improved
| Reported by: | imath | Owned by: | audrasjb |
|---|---|---|---|
| Priority: | low | Milestone: | 7.2 |
| Component: | Administration | Version: | 4.0 |
| Severity: | minor | Keywords: | has-patch has-screenshots |
| Cc: | Focuses: |
Description
If a plugin adds new media uploads settings fields when it's not possible to edit the uploads path/url, the table's first row unlike following is displayed in one cell instead of using the full row space. See screenshot below.
I believe checking for existing custom media uploads settings should also be checked when choosing whether to use the colspan="2" attribute of the the first cell. See attached patch.
Attachments (6)
Change History (16)
#2
@
2 months ago
This is a 4.8 regression rather than 4.0, if the version field is worth narrowing.
Before [40823] the checkbox row sat outside the conditional and always spanned both columns:
<?php endif; ?> <tr> <th scope="row" colspan="2" class="th-full">
[40823] (#37004, HTML validation fixes) moved the row inside the conditional in order to change the th to a td, and carried colspan="2" onto only the editable-paths branch:
<tr> <td colspan="2" class="td-full"> <?php else : ?> <tr> <td class="td-full"> <?php endif; ?>
forms.css still dates it from the other side: .form-table th.th-full, /* Not used by core. Back-compat for pre-4.8 */.
So on the else branch — what a site with default upload paths gets — the cell has no colspan. With no plugin fields the table has one column and the cell fills it, so nothing looks wrong. do_settings_fields( 'media', 'uploads' ) on the next line invites a second column, and once anything takes it, .form-table th { width: 200px } claims the first and the core label wraps, which is the screenshot above.
I measured this on a local install at a 1238px content width, with one plugin field registered in the uploads section:
| cell width | label height | |
|---|---|---|
| no plugin fields, no colspan (trunk) | 1238px | 17px |
no plugin fields, colspan="2" | 1238px | 17px |
| one plugin field, no colspan (trunk) | 210px | 55px |
one plugin field, colspan="2" | 1238px | 17px |
The first two rows are identical because colspan="2" on a lone cell in a one-column table spans what it already spanned. The branch therefore does not need to know whether fields exist: restoring the unconditional row fixes the reported case and leaves the no-fields case unchanged.
That would make has_settings_fields() unnecessary for this, which seems worth avoiding — a new public function is a larger commitment than the bug needs, and the @since 5.6.0 on the current patch has aged out. Refreshed patch attached: it closes the conditional above the row and restores a single <td colspan="2" class="td-full">, keeping the td/td-full markup [40823] introduced.
@
2 months ago
Closes the conditional above the row and restores the single unconditional cell — the pre-4.8 structure — while keeping the td/td-full markup r40823 was actually trying to fix.
This ticket was mentioned in PR #13322 on WordPress/wordpress-develop by @dpknauss.
2 months ago
#3
## Problem
On Settings > Media, "Organize my uploads into month- and year-based folders" wraps onto three lines as soon as any plugin registers a field in the uploads settings section.
## Cause
The row spanned both columns unconditionally until [40823] (#37004, HTML validation fixes) moved it inside the upload-path conditional in order to change its th to a td. That carried colspan="2" onto the editable-paths branch only:
<tr> <td colspan="2" class="td-full"> <?php else : ?> <tr> <td class="td-full"> <?php endif; ?>
The else branch is what a site with default upload paths gets. With no fields registered the table has one column and the cell fills it, so nothing looks wrong. The do_settings_fields( 'media', 'uploads' ) call on the next line invites a second column, and once anything takes it, .form-table th { width: 200px } claims the first and the core label wraps.
forms.css dates the change from the other side: .form-table th.th-full, /* Not used by core. Back-compat for pre-4.8 */.
## Fix
Close the conditional above the row and restore the single unconditional cell, keeping the td/td-full markup [40823] introduced.
Measured at a 1238px content width:
| cell width | label height | |
|---|---|---|
| no plugin fields, no colspan (trunk) | 1238px | 17px |
no plugin fields, colspan="2" | 1238px | 17px |
| one plugin field, no colspan (trunk) | 210px | 55px |
one plugin field, colspan="2" | 1238px | 17px |
The first two rows are identical because colspan="2" on a lone cell in a one-column table spans what it already spanned, so no check for registered fields is needed and rendering is unchanged for sites without them.
## Testing instructions
- Make sure
upload_pathandupload_url_pathare at their defaults, so the paths are locked (the common case). - Visit Settings > Media and confirm the checkbox is on one line.
- Drop this in
wp-content/mu-plugins/:
<?php add_action( 'admin_init', function () { add_settings_field( 'demo_field', 'Demo Field', function () { echo '<input type="text" class="regular-text">'; }, 'media', 'uploads' ); } );
- Reload Settings > Media. On trunk the checkbox label wraps onto three lines in a 200px column; with this change it stays on one line and the new field renders below it.
Props imath for the report and diagnosis.
@dpknauss commented on PR #13322:
2 months ago
#5
The props line above credits only me. imath reported this on #51190, worked out the cause, and attached the first patch — this PR takes a different route to the same fix, but the diagnosis is theirs.
For SVN:
Props imath, dpknauss.
@dhruvang21 commented on PR #13322:
2 months ago
#7
#8
@
8 weeks ago
## Test Report
### Environment
- OS: Windows 11
- Local wordpress-develop Docker (
http://localhost:8080) - PR tested: https://github.com/WordPress/wordpress-develop/pull/13322
### Reproduction steps
- Keep default upload path / URL (locked uploads path UI).
- Register a custom settings field on the
media/uploadssection via a must-use plugin. - Open Settings → Media and inspect the “Organize my uploads into month- and year-based folders” row.
### Results
Before (trunk):
- The checkbox cell renders as
<td class="td-full">with nocolspan. - Measured width ~210px inside a ~1078px table, so the row does not span full width when a plugin field is present.
After (PR #13322):
- The checkbox cell renders as
<td colspan="2" class="td-full">. - Measured width matches the table width (~1078px).
- Layout looks correct with the custom uploads field present.
### Conclusion
The issue is reproducible on trunk, and PR #13322 fixes it cleanly.
Screenshots (before/after) attached.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)

I'm going to guess this has existed since at least 4.0 if not pre-3.0, just bumping the version back to clear a
trunkreport.