• Hello,

    I just realized there is a way to get medium sized images to be zoomcropped to fit the exact measurements you set in your WordPress options.

    Now, I’d like to make this optional.
    If it’s a landscape mode pic, zoomcrop it, if it’s a portrait mode, then don’t.

    I believe it has something to do with image_make_intermediate_size. Now, I don’t want to edit any core files, so I’m looking for a way to hook into that and do some height/width calculations before it’s being executed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mores

    (@mores)

    I tried using this in my functions.php:

    function dm_image_make_intermediate_size($file, $width, $height, $crop=false) {
    	if ( $width || $height ) {
    		if ($width >> $height) {$crop=true;}
    		$resized_file = image_resize($file, $width, $height, $crop);
    		if ( !is_wp_error($resized_file) && $resized_file && $info = getimagesize($resized_file) ) {
    			$resized_file = apply_filters('image_make_intermediate_size', $resized_file);
    			return array(
    				'file' => basename( $resized_file ),
    				'width' => $info[0],
    				'height' => $info[1],
    			);
    		}
    	}
    	return false;
    }
    add_filter('image_make_intermediate_size', 'dm_image_make_intermediate_size', 11, 4);

    But I get an error message saying there’s parameter 2 and 3 missing.

    well, I’m having the same problem…
    Have you figure it out yet?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘image_make_intermediate_size’ is closed to new replies.