Index: webfm_images.module
===================================================================
--- webfm_images.module (Revision 409)
+++ webfm_images.module (Arbeitskopie)
@@ -74,9 +74,11 @@
$sizes = _webfm_images_get_sizes();
$form['#type'] = 'item';
- $form['#description'] = t('Select various pixel dimensions, "thumbnail" is required.
- For each Label and dimension you enter a new "right-click" menu option will become available in WebFM for image files.
- Clicking the menu item with resize the image based on these settings.');
+ $form['#description'] = t('Select various pixel dimensions, "thumbnail" is required.
+ If you enter width and height the images will be scaled to fit into the entered dimensions preserving aspect ratio.
+ If you enter height only, or width only the images will be scaled to fixed height or fixed width as entered also preserving aspect ratio.
+ For each Label and dimension you enter a new "right-click" menu option will become available in WebFM for image files.
+ Clicking the menu item will resize the image based on these settings.');
$form['#tree'] = TRUE;
$form['#theme'] = 'webfm_images_settings_sizes_form';
for ($i = 0; $i < 5; $i++) {
@@ -102,7 +104,7 @@
$rows[] = $row;
}
- $output = theme('table', $header, $rows);
+ $output = theme('table', $header, $rows, $attributes = array('summary' => 'webfm_images_sizes'));
$output .= drupal_render($form);
return $output;
@@ -160,6 +162,16 @@
}
}
+ $original_size = getimagesize ($dir .'/'. $filename);
+ // scale to a fixed width
+ if (!$height) {
+ $height = ($width / $original_size[0]) * $original_size[1];
+ }
+ // scale to a fixed height
+ if (!$width) {
+ $width = ($height / $original_size[1]) * $original_size[0];
+ }
+
if (image_scale($file->fpath, $path, $width, $height)){ //create our new file
$err = array();
webfm_insert_file($path, $err); //add it to the database