02/22/2018 at 8:27 pm
#452751
Keymaster
@ Kitty
I see… yes, these function will always scale the image up or down and crop, if needed. Here is a possible solution.
Add the following to the wp-config.php file:
define( 'CN_IMAGE_MAX_WIDTH', 600 );
define( 'CN_IMAGE_MAX_HEIGHT', 400 );
That will set the max uploaded image size. Any above that will be scaled down proportionally. Anything below that size will be left as is, not scaled up.
In the template, instead of using the $entry->getImage(... block of code.
Use this:
$logoHREF = $entry->getOriginalImageURL('logo');
//$photHREF = $entry->getOriginalImageURL('photo');
if ( ! empty( $logoHREF ) ) {
echo "<image src='$logoHREF'>";
}
That will simply output the image as uploaded.
Another handy line if code:
$entry->getImageMeta( array( 'type' => 'logo', 'size' => 'original' ) );
That will return an array of image metadata which includes width, height, size, mime, type, URL and path.
Hope that helps!
