wp_get_mime_types

Retrieve list of mime types and file extensions.

Description

(array) wp_get_mime_types(); 

Returns (array)

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


Usage

  1. if ( !function_exists( 'wp_get_mime_types' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_get_mime_types(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_get_mime_types() { 
  2. /** 
  3. * Filters the list of mime types and file extensions. 
  4. * This filter should be used to add, not remove, mime types. To remove 
  5. * mime types, use the {@see 'upload_mimes'} filter. 
  6. * @since 3.5.0 
  7. * @param array $wp_get_mime_types Mime types keyed by the file extension regex 
  8. * corresponding to those types. 
  9. */ 
  10. return apply_filters( 'mime_types', array( 
  11. // Image formats. 
  12. 'jpg|jpeg|jpe' => 'image/jpeg',  
  13. 'gif' => 'image/gif',  
  14. 'png' => 'image/png',  
  15. 'bmp' => 'image/bmp',  
  16. 'tiff|tif' => 'image/tiff',  
  17. 'ico' => 'image/x-icon',  
  18. // Video formats. 
  19. 'asf|asx' => 'video/x-ms-asf',  
  20. 'wmv' => 'video/x-ms-wmv',  
  21. 'wmx' => 'video/x-ms-wmx',  
  22. 'wm' => 'video/x-ms-wm',  
  23. 'avi' => 'video/avi',  
  24. 'divx' => 'video/divx',  
  25. 'flv' => 'video/x-flv',  
  26. 'mov|qt' => 'video/quicktime',  
  27. 'mpeg|mpg|mpe' => 'video/mpeg',  
  28. 'mp4|m4v' => 'video/mp4',  
  29. 'ogv' => 'video/ogg',  
  30. 'webm' => 'video/webm',  
  31. 'mkv' => 'video/x-matroska',  
  32. '3gp|3gpp' => 'video/3gpp', // Can also be audio 
  33. '3g2|3gp2' => 'video/3gpp2', // Can also be audio 
  34. // Text formats. 
  35. 'txt|asc|c|cc|h|srt' => 'text/plain',  
  36. 'csv' => 'text/csv',  
  37. 'tsv' => 'text/tab-separated-values',  
  38. 'ics' => 'text/calendar',  
  39. 'rtx' => 'text/richtext',  
  40. 'css' => 'text/css',  
  41. 'htm|html' => 'text/html',  
  42. 'vtt' => 'text/vtt',  
  43. 'dfxp' => 'application/ttaf+xml',  
  44. // Audio formats. 
  45. 'mp3|m4a|m4b' => 'audio/mpeg',  
  46. 'ra|ram' => 'audio/x-realaudio',  
  47. 'wav' => 'audio/wav',  
  48. 'ogg|oga' => 'audio/ogg',  
  49. 'mid|midi' => 'audio/midi',  
  50. 'wma' => 'audio/x-ms-wma',  
  51. 'wax' => 'audio/x-ms-wax',  
  52. 'mka' => 'audio/x-matroska',  
  53. // Misc application formats. 
  54. 'rtf' => 'application/rtf',  
  55. 'js' => 'application/javascript',  
  56. 'pdf' => 'application/pdf',  
  57. 'swf' => 'application/x-shockwave-flash',  
  58. 'class' => 'application/java',  
  59. 'tar' => 'application/x-tar',  
  60. 'zip' => 'application/zip',  
  61. 'gz|gzip' => 'application/x-gzip',  
  62. 'rar' => 'application/rar',  
  63. '7z' => 'application/x-7z-compressed',  
  64. 'exe' => 'application/x-msdownload',  
  65. 'psd' => 'application/octet-stream',  
  66. 'xcf' => 'application/octet-stream',  
  67. // MS Office formats. 
  68. 'doc' => 'application/msword',  
  69. 'pot|pps|ppt' => 'application/vnd.ms-powerpoint',  
  70. 'wri' => 'application/vnd.ms-write',  
  71. 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',  
  72. 'mdb' => 'application/vnd.ms-access',  
  73. 'mpp' => 'application/vnd.ms-project',  
  74. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',  
  75. 'docm' => 'application/vnd.ms-word.document.macroEnabled.12',  
  76. 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',  
  77. 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12',  
  78. 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',  
  79. 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',  
  80. 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',  
  81. 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',  
  82. 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',  
  83. 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',  
  84. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',  
  85. 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12',  
  86. 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',  
  87. 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',  
  88. 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',  
  89. 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12',  
  90. 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12',  
  91. 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',  
  92. 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12',  
  93. 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote',  
  94. 'oxps' => 'application/oxps',  
  95. 'xps' => 'application/vnd.ms-xpsdocument',  
  96. // OpenOffice formats. 
  97. 'odt' => 'application/vnd.oasis.opendocument.text',  
  98. 'odp' => 'application/vnd.oasis.opendocument.presentation',  
  99. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',  
  100. 'odg' => 'application/vnd.oasis.opendocument.graphics',  
  101. 'odc' => 'application/vnd.oasis.opendocument.chart',  
  102. 'odb' => 'application/vnd.oasis.opendocument.database',  
  103. 'odf' => 'application/vnd.oasis.opendocument.formula',  
  104. // WordPerfect formats. 
  105. 'wp|wpd' => 'application/wordperfect',  
  106. // iWork formats. 
  107. 'key' => 'application/vnd.apple.keynote',  
  108. 'numbers' => 'application/vnd.apple.numbers',  
  109. 'pages' => 'application/vnd.apple.pages',  
  110. ) );