Index: image_resize_filter.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/image_resize_filter/image_resize_filter.module,v retrieving revision 1.35 diff -u -r1.35 image_resize_filter.module --- image_resize_filter.module 16 Nov 2009 04:31:35 -0000 1.35 +++ image_resize_filter.module 16 Nov 2009 05:36:47 -0000 @@ -131,7 +131,7 @@ $form['image_resize']['image_resize_filter_image_locations_'. $format] = array( '#type' => 'checkboxes', '#title' => t('Resize images stored'), - '#options' => array('local' => t('Locally'), 'remote' => t('On remote servers')), + '#options' => array('local' => t('Locally'), 'remote' => t('On remote servers (note: this copies all remote images locally)')), '#default_value' => variable_get('image_resize_filter_image_locations_'. $format, array('local')), '#required' => TRUE, '#description' => t('This option will determine which images will be analyzed for <img> tag differences. Enabling resizing of remote images can have performance impacts, as all images in the filtered text needs to be transfered via HTTP each time the filter cache is cleared.'), @@ -239,6 +239,23 @@ $img_tag = $matches[3][$key]; $src = $matches[4][$key]; + // Determine if this is a local or remote file. + $location = 'unknown'; + if (strpos($src, '/') === 0 || strpos($src, '.') === 0) { + $location = 'local'; + } + elseif (preg_match('/http[s]?:\/\/'. preg_quote($_SERVER['HTTP_HOST'], '/') .'/', $src)) { + $location = 'local'; + } + elseif (strpos($src, 'http') === 0) { + $location = 'remote'; + } + + // If not resizing images in this location, continue on to the next image. + if (!in_array($location, $settings['image_locations'])) { + continue; + } + $width = NULL; $height = NULL; $needs_height = FALSE; @@ -268,7 +285,9 @@ } // If height and width are both missing, nothing to do here. - if (!$width && !$height) { + // If height and width are both 1, assume this is a tracking image that + // also should not be modified. + if (($location == 'local' && !$width && !$height) || (($width == 1) && ($height == 1))) { continue; } @@ -280,23 +299,6 @@ $title = $title_matches[1]; } - // Determine if this is a local or remote file. - $location = 'unknown'; - if (strpos($src, '/') === 0 || strpos($src, '.') === 0) { - $location = 'local'; - } - elseif (preg_match('/http[s]?:\/\/'. preg_quote($_SERVER['HTTP_HOST'], '/') .'/', $src)) { - $location = 'local'; - } - elseif (strpos($src, 'http') === 0) { - $location = 'remote'; - } - - // If not resizing images in this location, continue on to the next image. - if (!in_array($location, $settings['image_locations'])) { - continue; - } - // Convert the URL to a local path. $local_path = NULL; if ($location == 'local') { @@ -345,17 +347,21 @@ $actual_height = $image_size[1]; // If either height or width is missing, calculate the other. - if (!$height) { + if (!$height && $width) { $ratio = $actual_height/$actual_width; $height = round($ratio * $width); } - elseif (!$width) { + elseif ($height && !$width) { $ratio = $actual_width/$actual_height; $width = round($ratio * $height); } + else { + $height = $actual_height; + $width = $actual_width; + } // Finally, if width and heights match up, don't do anything. - if ($actual_width == $width && $actual_height == $height) { + if ($location == 'local' && $actual_width == $width && $actual_height == $height) { continue; }