diff -Naur old/image_resize_filter.module new/image_resize_filter.module --- old/image_resize_filter.module 2011-12-13 13:39:46.385723800 +0000 +++ new/image_resize_filter.module 2011-12-15 15:01:34.894462700 +0000 @@ -100,9 +100,30 @@ 'image_resize_filter_form' => array( 'arguments' => array('form' => NULL), ), + // Patch by AMS -- Register the theme_ ... function + 'image_resize_filter_scale_factor' => array( + 'arguments' => array('height' => NULL, 'width' => NULL), + ), + ); } +// Patch by AMS -- Null version of Hook. A Scale Factor of 1 is ignored. +/** + * Implementation of theme_image_resize_filter_scale_factor(). + * + * Allows the Theme to apply a further scaling of images, + * e.g. to reduce the size for small mobile phone screens. + * + * Parameters Passes Height and Width of image (in pixels) to allow the theme + * to adjust the scaling to size of original (if required) + * Return A numeric (float) value by which the height and width will be multiplied. + * E.g. 1 = no change. 0.5 = half size. + */ + function theme_image_resize_filter_scale_factor ($height, $width) { + return 1; +} + /** * Implementation of hook_file_download(). */ @@ -364,6 +385,7 @@ // If this is a remote image, retreive it to check its size. if ($location == 'remote') { $result = drupal_http_request($src); +drupal_set_message($result->code); if ($result->code == 200) { $tmp_file = tempnam(file_directory_temp(), 'image_resize_filter_'); $handle = fopen($tmp_file, 'w'); @@ -400,6 +422,17 @@ $ratio = $actual_width/$actual_height; $attributes['width'] = (int) round($ratio * $attributes['height']); } + + // Patch by AMS + // Now the target size is established, call a theme function hook to allow + // themes to scale the target size, e.g. for mobile screen sizes + $factor = theme('image_resize_filter_scale_factor', $attributes['height'], $attributes['width']); + $factor = floatval($factor); // In case get e.g. a string returned + // Only need action if there is some response + if ($factor>0 && $factor!=1) { + $attributes['width'] = (int) round($factor * $attributes['width']); + $attributes['height'] = (int) round($factor * $attributes['height']); + } // Determine if this image requires a resize. if (!isset($resize)) {