mime_types WordPress Filter Hook

Mime types are the file types that are associated with specific applications. For example, the mime type for Microsoft Word files is application/msword. When you upload a file to a WordPress site, WordPress will attempt to determine the mime type of the file. If WordPress is unable to determine the mime type, then it will fall back to using a default mime type. The mime_types hook allows you to add your own custom mime types to WordPress. This can be useful if you have a custom file type that you want to be able to upload to your WordPress site. For example, if you have a custom image file type that you use for your business, you can add the mime type for that file type to WordPress so that you can upload it to your site. To add a custom mime type to WordPress, you need to first add the mime type to the $mime_types array. The array key should be the extension of the file type, and the array value should be the mime type. For example, to add the mime type for the custom image file type mentioned above, you would add the following to the $mime_types array: 'jpg' => 'image/jpeg', Once you have added the custom mime type to the $mime_types array, you need to call the wp_update_mime_types() function. This function will update the WordPress database with the new mime type information.

apply_filters( 'mime_types', string[] $wp_get_mime_types ) #

Filters the list of mime types and file extensions.


Description

This filter should be used to add, not remove, mime types. To remove mime types, use the ‘upload_mimes’ filter.


Top ↑

Parameters

$wp_get_mime_types

(string[])Mime types keyed by the file extension regex corresponding to those types.


Top ↑

Source

File: wp-includes/functions.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.5.0Introduced.

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
Show More