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
2429      if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
2430
2431           // Attempt to figure out what type of image it actually is
2432           $imgstats = @getimagesize( $file );
2433
2434           // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
2435           if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
2436                // This is a simplified array of MIMEs that getimagesize() can detect and their extensions
2437                // You shouldn't need to use this filter, but it's here just in case
2438                $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
2439                     'image/jpeg' => 'jpg',
2440                     'image/png'  => 'png',
2441                     'image/gif'  => 'gif',
2442                     'image/bmp'  => 'bmp',
2443                     'image/tiff' => 'tif',
2444                ) );
2445
2446                // Replace whatever is after the last period in the filename with the correct extension
2447                if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {