JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
revamped uploaded image handling, added thumbnailing support to metaform
[wfpl.git] / metaform / template.php
index bdd7da1..1822ff3 100644 (file)
@@ -25,7 +25,13 @@ define('~file_name.upper~_DB_FIELDS', '~db_fields~');
 # Set this to the path to your uploads directory. It can be relative to the
 # location of this script. IT MUST END WITH A SLASH
 $GLOBALS['upload_directory'] = 'uploads/';
-<!--~end~--><!--~opt_http_pass_1 start~-->
+<!--~end~--><!--~image_settings start~-->
+$GLOBALS['~name~_max_width'] = '400';
+$GLOBALS['~name~_max_height'] = '400';<!--~thumb_settings start~-->
+$GLOBALS['~name~_thumb_max_width'] = '70';
+$GLOBALS['~name~_thumb_max_height'] = '70';
+$GLOBALS['~name~_file_name'] = uniqid() . getmypid() . '.jpg'; # comment this out to use uploader's filename
+<!--~end~--><!--~end~--><!--~opt_http_pass_1 start~-->
 # Define the username and password required to view this form:
 define('AUTH_REALM', '~file_name~ administration area');
 define('AUTH_USER', 'fixme');
@@ -42,12 +48,12 @@ require_once('code/wfpl/upload.php');<!--~end~-->
 function ~file_name~_get_fields() {<!--~formats start~-->
        $~name~ = format_~format~($_REQUEST['~name~']<!--~pulldown_format_extra start~-->, '~name~'<!--~end~-->);<!--~end~--><!--~image_upload start~-->
        if($_FILES['~name~'] && $_FILES['~name~']['error'] == 0) {
-               $~name~ = substr(save_uploaded_image('~name~', $GLOBALS['upload_directory']), strlen($GLOBALS['upload_directory']));
+               $~name~ = convert_uploaded_image('~name~', $GLOBALS['upload_directory'] . $GLOBALS['~name~_file_name'], $GLOBALS['~name~_max_width'], $GLOBALS['~name~_max_height']<!--~thumb_upload_params start~-->, $GLOBALS['~name~_thumb_max_width'], $GLOBALS['~name~_thumb_max_height']<!--~end~-->);
        } else {
                if($_REQUEST['delete_~name~'] == 'Yes') {
                        $~name~ = '';
                } else {
-                       $~name~ = format_filename($_REQUEST['old_~name~']);
+                       $~name~ = format_image_w_h<!--~thumb_w_h start~-->_thumb_w_h<!--~end~-->($_REQUEST['old_~name~']);
                }
        }<!--~end~-->