Make WordPress Core

Opened 9 years ago

Last modified 3 years ago

#34064 new enhancement

Filter the file type error message

Reported by: kraftbj's profile kraftbj Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Filesystem API Keywords:
Focuses: Cc:


When uploading a file type that is not permitted, the error Sorry, this file type is not permitted for security reasons. is returned.

By adding a filter, a plugin/site admin can add a customized message.

An example use case: A plugin that allows a front-end post submission system that allow file add-ons. By filtering the response, the author/admin can give more detailed specifications including allowable file types, if desired.

Example function of the filter in psudocode:

add_filter( 'upload_filetype_error', 'bk_test_error' );
function bk_test_error() {
	$allowed = get_allowed_mime_types();
	$message = "This type of file is not allowed! Please use one of the following: " . implode( ', ', array_keys( $allowed ) );
	return $message;

Attachments (1)

34064.diff (955 bytes) - added by kraftbj 9 years ago.
first pass at filter.

Download all attachments as: .zip

Change History (2)

9 years ago

first pass at filter.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

3 years ago

Note: See TracTickets for help on using tickets.