Codex

Function Reference/get allowed mime types

Contents

Description

Retrieve list of allowed mime types and file extensions.

Usage

<?php get_allowed_mime_types(); ?>

Parameters

None.

Return Values

(array) 
Array of mime types keyed by the file extension regex corresponding to those types.

Examples

Function to retrieve the mime type icon of a file by its extension

<?php
function get_icon_by_file_extension($file_ext) {
  $mimes = get_allowed_mime_types();
  foreach ($mimes as $type => $mime) {
    if (strpos($type, $file_ext) !== false) {
      return wp_mime_type_icon($mime);
    }
  }
}
?>
<img src="<?php echo get_icon_by_file_extension('mp4') ?>" />

Change Log

Since: 2.8.6

Source File

get_allowed_mime_types() is located in wp-includes/functions.php