requiring specific image dimensions
Hey Ray
Am trying to modify a function that checks for width of an uploaded image to one that checks both width and height:
I have this for the width only
<?php
if ( !function_exists( "WADFP_getImageWidth" ) ) {
function WADFP_getImageWidth( $fileField ) {
$WA_ImageContentTypes = array( "image/gif" => true, "image/jpeg" => true, "image/pjpeg" => true, "image/x-png" => true, "image/png" => true );
$width = -1;
if ( isset( $fileField ) && isset( $fileField[ "tmp_name" ] ) && isset( $fileField[ "type" ] ) && isset( $WA_ImageContentTypes[ $fileField[ "type" ] ] ) ) {
$dimensions = getimagesize( $fileField[ "tmp_name" ] );
$width = $dimensions[ 0 ];
}
return $width;
}
}
?>
and am hoping that I have got this 'right' to check both height and width
<?php
if ( !function_exists( "WADFP_getImageDimensions" ) ) {
function WADFP_getImageDimensions( $fileField ) {
$WA_ImageContentTypes = array( "image/gif" => true, "image/jpeg" => true, "image/pjpeg" => true, "image/x-png" => true, "image/png" => true );
$dimensions = array('width' => -1, 'height' => -1);
if ( isset( $fileField ) && isset( $fileField[ "tmp_name" ] ) && isset( $fileField[ "type" ] ) && isset( $WA_ImageContentTypes[ $fileField[ "type" ] ] ) ) {
$imageInfo = getimagesize( $fileField[ "tmp_name" ] );
$dimensions['width'] = $imageInfo[0];
$dimensions['height'] = $imageInfo[1];
}
return $dimensions;
}
}
?>
So if the latter is correct, how woudl I structure the validation to check for both where width == 700 and height== 380?
(this is what I've been using for just the width validation
$WAFV_Errors .= WAValidateNM((!empty($_FILES["ImageAside"]["name"])?WADFP_getImageWidth($_FILES["ImageAside"]):"") . "",700,700,"",",.",false,5);
thanks
Jamie