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
1819      if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
1820
1821           // Attempt to figure out what type of image it actually is
1822           $imgstats = @getimagesize( $file );
1823
1824           // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
1825           if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
1826                // This is a simplified array of MIMEs that getimagesize() can detect and their extensions
1827                // You shouldn't need to use this filter, but it's here just in case
1828                $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
1829                     'image/jpeg' => 'jpg',
1830                     'image/png'  => 'png',
1831                     'image/gif'  => 'gif',
1832                     'image/bmp'  => 'bmp',
1833                     'image/tiff' => 'tif',
1834                ) );
1835
1836                // Replace whatever is after the last period in the filename with the correct extension
1837                if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {