--- brilliant_gallery.module 2008-03-13 18:18:04.000000000 +0100 +++ brilliant_gallery.module.fixed 2008-05-04 12:35:22.000000000 +0200 @@ -139,11 +139,19 @@ function brilliant_gallery_admin() { ); $form['brilliant_gallery_maxwidth'] = array( '#type' => 'textfield', - '#title' => t('Maximum width of full image'), + '#title' => t('Width of area into which the full image will be fitted.'), '#default_value' => variable_get('brilliant_gallery_maxwidth', '1000'), '#size' => 5, '#maxlength' => 5, - '#description' => t("Very large images will be scaled down to this width (in pixels) for display before they get displayed by the overlay browser.") + '#description' => t("Very large images will be scaled down to fit into an area of this width (in pixels) for display before they get displayed by the overlay browser.") + ); + $form['brilliant_gallery_maxheight'] = array( + '#type' => 'textfield', + '#title' => t('Height of area into which the full image will be fitted.'), + '#default_value' => variable_get('brilliant_gallery_maxheight', '800'), + '#size' => 5, + '#maxlength' => 5, + '#description' => t("Very large images will be scaled down to fit into an area of this height (in pixels) for display before they get displayed by the overlay browser.") ); $form['brilliant_gallery_caption'] = array( '#type' => 'checkbox', @@ -261,6 +269,7 @@ function render_brilliant_gallery( $this $overbrowser = variable_get('brilliant_gallery_overbrowser', 'thickbox'); $showcaption = variable_get('brilliant_gallery_caption', ''); $fullresolutionmaxwidth = variable_get('brilliant_gallery_maxwidth', '1000'); # Totally full resolution display would be impractical, so this is the maximum width of "full" resolution. + $fullresolutionmaxheight = variable_get('brilliant_gallery_maxheight', '800'); # Totally full resolution display would be impractical, so this is the maximum height of "full" resolution. $path = url(file_directory_path() . '/' . $galleryfolder, NULL, NULL, TRUE); # url() ads i18n codes to the URL ... we need to remove them here... if ( $langcode <> '' ) { @@ -290,27 +299,31 @@ function render_brilliant_gallery( $this # this is a horizontal image $retval_dimensions[$poct]['imgw'] = $imagewidth; $retval_dimensions[$poct]['imgh'] = round( ($temp[1]/$temp[0]) * $imagewidth ); + } else { + # this is a vertical image .... a + $retval_dimensions[$poct]['imgw'] = round( ($temp[0]/$temp[1])*($temp[0]/$temp[1])*$imagewidth ); + $retval_dimensions[$poct]['imgh'] = round( ($temp[0]/$temp[1])*$imagewidth ); + } + if ( $imagemaxh < $retval_dimensions[$poct]['imgh'] ) $imagemaxh = $retval_dimensions[$poct]['imgh']; + + # Is image width/height ratio more horizontally oriented than window ratio or more vertically oriented? + if ( ($temp[0]/$temp[1]) >= ($fullresolutionmaxwidth/$fullresolutionmaxheight) ) { + # the image is more horizontal oriented then the window if ( $temp[0] > $fullresolutionmaxwidth ) { $retval_dimensions[$poct]['imgwbig'] = $fullresolutionmaxwidth; $retval_dimensions[$poct]['imghbig'] = round( ($temp[1]/$temp[0]) * $fullresolutionmaxwidth ); } else { $retval_dimensions[$poct]['smallenough'] = true; } - #$result .= $imgw . ' / ' . $imgh; } else { - # this is a vertical image .... a - $retval_dimensions[$poct]['imgw'] = round( ($temp[0]/$temp[1])*($temp[0]/$temp[1])*$imagewidth ); - $retval_dimensions[$poct]['imgh'] = round( ($temp[0]/$temp[1])*$imagewidth ); - if ( $temp[0] > $fullresolutionmaxwidth ) { - $retval_dimensions[$poct]['imgwbig'] = round( ($temp[0]/$temp[1])*($temp[0]/$temp[1])*$fullresolutionmaxwidth ); - $retval_dimensions[$poct]['imghbig'] = round( ($temp[0]/$temp[1])*$fullresolutionmaxwidth ); + # the image is more vertically oriented then the window + if ( $temp[1] > $fullresolutionmaxheight ) { + $retval_dimensions[$poct]['imgwbig'] = round( ($temp[0]/$temp[1]) * $fullresolutionmaxheight ); + $retval_dimensions[$poct]['imghbig'] = $fullresolutionmaxheight; } else { $retval_dimensions[$poct]['smallenough'] = true; } - #$result .= $imgw . ' / ' . $imgh; } - if ( $imagemaxh < $retval_dimensions[$poct]['imgh'] ) $imagemaxh = $retval_dimensions[$poct]['imgh']; - } @closedir( $handle ); $maxpoct = count( $retval_dimensions ); @@ -540,4 +553,4 @@ function brilliant_gallery_filter_tips($ } } */