wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_get_image_mime › WordPress Function
Since4.7.1
Deprecatedn/a
› wp_get_image_mime ( $file )
Parameters: |
|
Returns: |
|
Defined at: |
|
Codex: |
Returns the real mime type of an image file.
This depends on exif_imagetype() or getimagesize() to determine real mime types.Related Functions: wp_get_image_editor, wp_save_image_file, _wp_get_image_size_from_meta, wp_get_theme, wp_create_image_subsizes
Source
function wp_get_image_mime( $file ) { /* * Use exif_imagetype() to check the mimetype if available or fall back to * getimagesize() if exif isn't avaialbe. If either function throws an Exception * we assume the file could not be validated. */ try { if ( is_callable( 'exif_imagetype' ) ) { $imagetype = exif_imagetype( $file ); $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false; } elseif ( function_exists( 'getimagesize' ) ) { $imagesize = @getimagesize( $file ); $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; } else { $mime = false; } } catch ( Exception $e ) { $mime = false; } return $mime; }