Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: intermediate_image_sizes

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

This hook occurs 2 times in this file.

Line Code
420      $msg = '';
421
422      if ( !is_array($backup_sizes) ) {
423           $msg->error = __('Cannot load image metadata.');
424           return $msg;
425      }
426
427      $parts = pathinfo($file);
428      $suffix = time() . rand(100, 999);
429      $default_sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
430
431      if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) {
432           $data = $backup_sizes['full-orig'];
433
434           if ( $parts['basename'] != $data['file'] ) {
435                if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {
436                     // delete only if it's edited image
437                     if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
438                          $delpath = apply_filters('wp_delete_file', $file);
 
Line Code
592
593           $meta['file'] = _wp_relative_upload_path($new_path);
594           $meta['width'] = imagesx($img);
595           $meta['height'] = imagesy($img);
596
597           list ( $uwidth, $uheight ) = wp_shrink_dimensions($meta['width'], $meta['height']);
598           $meta['hwstring_small'] = "height='$uheight' width='$uwidth'";
599
600           if ( $success && ('nothumb' == $target || 'all' == $target) ) {
601                $sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );
602                if ( 'nothumb' == $target )
603                     $sizes = array_diff( $sizes, array('thumbnail') );
604           }
605
606           $return->fw = $meta['width'];
607           $return->fh = $meta['height'];
608      } elseif ( 'thumbnail' == $target ) {
609           $sizes = array( 'thumbnail' );
610           $success = $delete = $nocrop = true;