wpsc_preview_image_cropping_method

Located in: misc.functions.php

Functions that call this hook: nzshpcrt_display_preview_image()

Arguments Accepted: 'cropping'

Version Introduced: 3.8.9

Description: Specify which scaling method to use (cropping or non-cropping).

Code in context:

[php firstline=”377″ highlight=”378″]

// select our scaling method

$scaling_method = apply_filters( ‘wpsc_preview_image_cropping_method’, ‘cropping’ );

// set both offsets to zero

$offset_x = $offset_y = 0;

// Here are the scaling methods, non-cropping causes black lines in tall images, but doesnt crop images.

switch ( $scaling_method ) {

case ‘cropping’:

// if the image is wider than it is high and at least as wide as the target width.

if ( ($source_h <= $source_w ) ) {

if ( $height < $width ) {

$temp_h = ($width / $source_w) * $source_h;

} else {

$temp_w = ($height / $source_h) * $source_w;

}

} else {

$temp_h = ($width / $source_w) * $source_h;

}

break;

case ‘non-cropping’:

default:

if ( $height < $width ) {

$temp_h = ($width / $source_w) * $source_h;

} else {

$temp_w = ($height / $source_h) * $source_w;

}

break;

}

[/php]