<?
	function smarty_validate_criteria_isImageSize($value, $empty, &$params, &$formvars) {

// If no params
if (!isset($params['field2']) or !isset($params['field3'])) {
trigger_error("SmartyValidate: [isImageSize] one of the parameters is missing.");
return false;
}

$_field = $params['field'];

// Nothing in the form
if(!isset($_FILES[$_field])) return false;
// No file uploaded
if($_FILES[$_field]['error'] == 4) return $empty;

$_maxWidth = $params['field2'];
$_maxHeight = $params['field3'];

// Get image dimensions
list($_width, $_height) = getimagesize($_FILES[$_field]['tmp_name']);

if ($_width > $_maxWidth or $_height > $_maxHeight) return false;

return true;
}

?>