sanitize_mime_type( string $mime_type ): string

Sanitizes a mime type

Parameters

$mime_typestringrequired
Mime type.

Return

string Sanitized mime type.

Source

function sanitize_mime_type( $mime_type ) {
	$sani_mime_type = preg_replace( '/[^-+*.a-zA-Z0-9\/]/', '', $mime_type );
	/**
	 * Filters a mime type following sanitization.
	 *
	 * @since 3.1.3
	 *
	 * @param string $sani_mime_type The sanitized mime type.
	 * @param string $mime_type      The mime type prior to sanitization.
	 */
	return apply_filters( 'sanitize_mime_type', $sani_mime_type, $mime_type );
}

Hooks

apply_filters( ‘sanitize_mime_type’, string $sani_mime_type, string $mime_type )

Filters a mime type following sanitization.

Changelog

VersionDescription
3.1.3Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.