Welcome, visitor! Log in
 

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.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

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
2406      if ( $type && 0 === strpos( $type, 'image/' ) && function_exists('getimagesize') ) {
2407
2408           // Attempt to figure out what type of image it actually is
2409           $imgstats = @getimagesize( $file );
2410
2411           // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME
2412           if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) {
2413                // This is a simplified array of MIMEs that getimagesize() can detect and their extensions
2414                // You shouldn't need to use this filter, but it's here just in case
2415                $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
2416                     'image/jpeg' => 'jpg',
2417                     'image/png'  => 'png',
2418                     'image/gif'  => 'gif',
2419                     'image/bmp'  => 'bmp',
2420                     'image/tiff' => 'tif',
2421                ) );
2422
2423                // Replace whatever is after the last period in the filename with the correct extension
2424                if ( ! empty( $mime_to_ext[ $imgstats['mime'] ] ) ) {