Index: image_resize_filter.module =================================================================== RCS file: /resizer/tortoise/image_resize_filter.module,v retrieving revision 1.1 diff -u -r1.1 image_resize_filter.module --- image_resize_filter.module 16 Apr 2009 10:16:01 -0000 +++ image_resize_filter.module 16 Apr 2009 10:16:15 -0000 @@ -1,5 +1,5 @@ '10', '#default_value' => variable_get('image_resize_filter_link_class_'. $format, ''), ); + $form['image_resize']['image_resize_filter_override_'. $format] = array( + '#type' => 'checkbox', + '#title' => t('Override the maximum width.'), + '#default_value' => variable_get('image_resize_filter_override_'. $format, 0), + ); + + $form['image_resize']['image_resize_filter_override_maxwidth_'. $format] = array( + '#type' => 'textfield', + '#title' => t('Set maximum width'), + '#size' => '10', + '#default_value' => variable_get('image_resize_filter_override_maxwidth_'. $format, ''), + ); return $form; } @@ -276,7 +290,21 @@ $ratio = $actual_width/$actual_height; $width = round($ratio * $height); } - + + $ori_expected_width = ""; + $ori_expected_height = ""; + if ($settings['override']) { + if ($width > $settings['maxwidth']){ + // Create own vars of the origional width to be replaced later on + $ori_expected_width = $width; + $ori_expected_height = $height; + // Override the expected width + $width = $settings['maxwidth']; + $ratio = $actual_height/$actual_width; + $height = round($ratio * $width); + } + } + // Finally, if width and heights match up, don't do anything. if ($actual_width == $width && $actual_height == $height) { continue; @@ -288,6 +316,7 @@ 'expected_size' => array('width' => $width, 'height' => $height), 'actual_size' => array('width' => $image_size[0], 'height' => $image_size[1]), 'add_properties' => array('width' => $needs_width, 'height' => $needs_height), + 'ori_expected_size' => array('width' => $ori_expected_width, 'height' => $ori_expected_height), 'original' => $src, 'location' => $location, 'local_path' => $local_path, @@ -391,6 +420,13 @@ $output .= $image['add_properties']['height'] ? ' height="'. $image['expected_size']['height'] .'"' : ''; $output .= $matches[3]; // The closing "/>". + + // See if there is need for an override, if so, replace width and height with override width and height. + if ($image['ori_expected_size']['width'] != ""){ + $output = str_replace('width="'.$image['ori_expected_size']['width'].'"', 'width="'.$image['expected_size']['width'].'"', $output); + $output = str_replace('height="'.$image['ori_expected_size']['height'].'"', 'height="'.$image['expected_size']['height'].'"', $output); + } + if ($settings['link']) { $class = !empty($settings['class']) ? ' class="'. $settings['class'] .'"' : ''; $output = ''. $output .'';