WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 5 weeks ago

#49483 new enhancement

'Upload file types' Setting field for multisite network settings should be textarea than text input

Reported by: shamalisulakhe Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3.2
Component: Administration Keywords: has-patch has-screenshots
Focuses: ui, multisite Cc:

Description

The setting field 'Upload file types' (CSS name='upload_filetypes') is currently a text input with visible width of 45 characters.
However, the default content of that field is 135 characters. Thus, it would be good to have it in the form of textarea to have a better look at all the content without the need for scrolling.

Steps to find -

  1. At a multisite WordPress installation, go to My Sites -> Network Admin -> Settings.
  2. Find the setting under the heading 'Upload Settings' with label 'Upload file types'.
  3. The default value in that field is as follows -

jpg jpeg png gif mov avi mpg 3gp 3g2 midi mid pdf doc ppt odt pptx docx pps ppsx xls xlsx key mp3 ogg flac m4a wav mp4 m4v webm ogv flv

Screenshots -

  1. Current (with input tag) - upload_filetypes_current.png
  2. Proposed (with textarea tag) - upload_filetypes_proposed.png

Attachments (5)

upload_filetypes_current.png (70.0 KB) - added by shamalisulakhe 7 months ago.
Current structure with input tag
upload_filetypes_proposed.png (78.2 KB) - added by shamalisulakhe 7 months ago.
Proposed structure with textarea tag
upload_filetypes-textarea.diff (967 bytes) - added by shamalisulakhe 7 months ago.
Patch file with proposed changes
upload_filetypes-textarea-49483.diff (1.6 KB) - added by shamalisulakhe 7 months ago.
Revised patch with logic to allow new lines in the textarea for upload_filetypes
upload_filetypes-textarea-49483-2.diff (1.7 KB) - added by shamalisulakhe 7 months ago.
Revised patch with logic for lowercase conversion and remove periods(.)

Download all attachments as: .zip

Change History (12)

@shamalisulakhe
7 months ago

Current structure with input tag

@shamalisulakhe
7 months ago

Proposed structure with textarea tag

@shamalisulakhe
7 months ago

Patch file with proposed changes

This ticket was mentioned in PR #159 on WordPress/wordpress-develop by shamalisulakhe.


7 months ago

#3 @shamalisulakhe
7 months ago

URL to find this field at a multisite installation -
{site_url}/wp-admin/network/settings.php

#4 @johnjamesjacoby
7 months ago

I do like this change.

It will introduce the ability for users to separate file types on new lines, not just spaces anymore.

The way this setting gets parsed should be tested to ensure that both new lines and spaces work the same.

@shamalisulakhe
7 months ago

Revised patch with logic to allow new lines in the textarea for upload_filetypes

#5 @shamalisulakhe
7 months ago

@johnjamesjacoby
I agree with your point.

I checked and found that new lines do not work as per current way of parsing the setting, so changed the parsing code to allow new lines as well as spaces. This has one more benefit that multiple spaces between two strings are also allowed.

Revised patch - upload_filetypes-textarea-49483.diff

#6 @shamalisulakhe
7 months ago

@johnjamesjacoby

I have noticed a few more things -

  1. If the filetypes are entered in upper case characters (such as ODT, WebM instead of odt, webm), they are not recognized and therefore allowed for media uploads.
  2. The user may enter the filetype in the form of an extension (such as .jpg instead of jpg), they are also not allowed.

In such cases, we should convert the filetypes to lowercases and remove periods(.) before saving them to site options. I have added these conversions in the revised patch-2.

Another concern is that -

I have added these modified conversion and parsing functionality in the function check_upload_mimes(), which is the only function in WP core where the site option upload_filetypes is fetched.
Thus, it is expected that the third-party plugins and themes use check_upload_mimes() function, instead of fetching the site option upload_filetypes directly in their code.

Revised patch - upload_filetypes-textarea-49483-2.diff

@shamalisulakhe
7 months ago

Revised patch with logic for lowercase conversion and remove periods(.)

#7 @shamalisulakhe
5 weeks ago

@johnjamesjacoby any update on this? Let me know if any changes are needed.

Note: See TracTickets for help on using tickets.