diff options
Diffstat (limited to 'inc/media.php')
-rw-r--r-- | inc/media.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/inc/media.php b/inc/media.php index 437a8d75f..5c84bed4b 100644 --- a/inc/media.php +++ b/inc/media.php @@ -2138,6 +2138,7 @@ function media_resize_imageGD($ext,$from,$from_w,$from_h,$to,$to_w,$to_h,$ofs_x= * * @param string $src - ID of media file * @param array $exts - alternative extensions to find other files for + * @return array - mime type => file ID * * @author Anika Henke <anika@selfthinker.org> */ @@ -2158,4 +2159,34 @@ function media_alternativefiles($src, $exts){ return $files; } +/** + * Check if video/audio is supported to be embedded. + * + * @param string $src - mimetype of media file + * @param string $type - type of media files to check ('video', 'audio', or none) + * @return boolean + * + * @author Anika Henke <anika@selfthinker.org> + */ +function media_supportedav($mime, $type=NULL){ + $supportedAudio = array( + 'ogg' => 'audio/ogg', + 'mp3' => 'audio/mpeg', + 'wav' => 'audio/wav', + ); + $supportedVideo = array( + 'webm' => 'video/webm', + 'ogv' => 'video/ogg', + 'mp4' => 'video/mp4', + ); + if ($type == 'audio') { + $supportedAv = $supportedAudio; + } elseif ($type == 'video') { + $supportedAv = $supportedVideo; + } else { + $supportedAv = array_merge($supportedAudio, $supportedVideo); + } + return in_array($mime, $supportedAv); +} + /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |