sanitize_mime_type() WordPress Function

The sanitize_mime_type() function is used to clean up a mime type string. This function is typically used to ensure that a mime type string is valid before passing it to another function.

sanitize_mime_type( string $mime_type ) #

Sanitizes a mime type


Parameters

$mime_type

(string)(Required)Mime type.


Top ↑

Return

(string) Sanitized mime type.


Top ↑

Source

File: wp-includes/formatting.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.3Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More