Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/a0020005e052a4c6b610 to your computer and use it in GitHub Desktop.
Save wokamoto/a0020005e052a4c6b610 to your computer and use it in GitHub Desktop.
[WordPress プラグイン開発のバイブル] P367 訂正
add_filter('upload_mimes', 'my_mime_types', 1, 1);
function my_mime_types($mime_types){
// 許可するファイルタイプを列挙した連想配列
// キーは拡張子を正規表現で、値は mime タイプ
$mime_types = array(
'jpg|jpeg|jpe' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
'bmp' => 'image/bmp',
'tif|tiff' => 'image/tiff',
);
return $mime_types;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment