Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_check_filetype [ WordPress Function ]

wp_check_filetype ( $filename, $mimes = null )
Parameters:
  • (string) $filename File name or path.
  • (array) $mimes Optional. Key is the file extension with value as the mime type.
Returns:
  • (array) Values with extension first and mime type.
Defined at:



Retrieve the file type from the file name.

You can optionally define the mime array, if needed.

Source


<?php
function wp_check_filetype$filename$mimes null ) {
    if ( empty(
$mimes) )
        
$mimes get_allowed_mime_types();
    
$type false;
    
$ext false;

    foreach ( 
$mimes as $ext_preg => $mime_match ) {
        
$ext_preg '!\.(' $ext_preg ')$!i';
        if ( 
preg_match$ext_preg$filename$ext_matches ) ) {
            
$type $mime_match;
            
$ext $ext_matches[1];
            break;
        }
    }

    return 
compact'ext''type' );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Kullanýcý Tartýþmalarý [ wordpress.org ]

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics