Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: getimagesize_mimes_to_exts

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
2501      if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
2502
2503           // Attempt to figure out what type of image it actually is
2504           $imgstats = @getimagesize( $file );
2505
2506           // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
2507           if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
2508                // This is a simplified array of MIMEs that getimagesize() can detect and their extensions
2509                // You shouldn't need to use this filter, but it's here just in case
2510                $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
2511                     'image/jpeg' => 'jpg',
2512                     'image/png'  => 'png',
2513                     'image/gif'  => 'gif',
2514                     'image/bmp'  => 'bmp',
2515                     'image/tiff' => 'tif',
2516                ) );
2517
2518                // Replace whatever is after the last period in the filename with the correct extension
2519                if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {