Project

General

Profile

Bug #17107 » typo3-v443dev-rev8607.patch

Administrator Admin, 2010-08-20 14:47

View differences:

class.tx_cssstyledcontent_pi1.php (working copy)
}
}
// All columns have the same width:
$defaultColumnWidth = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*($borderThickness+$borderSpace)*2)/$colCount);
// max usuable width for images (without spacers and borders)
$netW = $maxW - $colspacing * ($colCount - 1) - $colCount * $border * ($borderThickness + $borderSpace) * 2;
// max width of each image if all columns have the same width
$defaultColumnWidth = floor($netW / $colCount);
// Specify the maximum width for each column
$columnWidths = array();
......
$gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
$gifCreator->init();
$relations_cols = Array();
$imgWidths = array(); // contains the individual width of all images after scaling to $equalHeight
for ($a=0; $a<$imgCount; $a++) {
$imgKey = $a+$imgStart;
$imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
$rel = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
if ($rel) { // if relations is zero, then the addition of this value is omitted as the image is not expected to display because of some error.
$relations_cols[floor($a/$colCount)] += $imgInfo[0]/$rel; // counts the total width of the row with the new height taken into consideration.
$imgWidths[$a] = $imgInfo[0] / $rel;
$relations_cols[floor($a/$colCount)] += $imgWidths[$a]; // counts the total width of the row with the new height taken into consideration.
}
}
}
......
$imageRowsFinalWidths = Array(); // contains the width of every image row
$imgsTag = array(); // array index of $imgsTag will be the same as in $imgs, but $imgsTag only contains the images that are actually shown
$origImages = array();
$rowIdx = 0;
for ($a=0; $a<$imgCount; $a++) {
$imgKey = $a+$imgStart;
$totalImagePath = $imgPath.$imgs[$imgKey];
......
$imgConf = $conf[$imgObjNum.'.'];
if ($equalHeight) {
$scale = 1;
$totalMaxW = $defaultColumnWidth*$colCount;
$rowTotalMaxW = $relations_cols[floor($a/$colCount)];
if ($rowTotalMaxW > $totalMaxW) {
$scale = $rowTotalMaxW / $totalMaxW;
if ($a % $colCount == 0) {
// a new row startsS
$accumWidth = 0; // reset accumulated net width
$accumDesiredWidth = 0; // reset accumulated desired width
$rowTotalMaxW = $relations_cols[$rowIdx];
if ($rowTotalMaxW > $netW) {
$scale = $rowTotalMaxW / $netW;
} else {
$scale = 1;
}
$desiredHeight = $equalHeight / $scale;
$rowIdx++;
}
$availableWidth= $netW - $accumWidth; // this much width is available for the remaining images in this row (int)
$desiredWidth= $imgWidths[$a] / $scale; // theoretical width of resized image. (float)
$accumDesiredWidth+= $desiredWidth; // add this width. $accumDesiredWidth becomes the desired horizontal position
// calculate width by comparing actual and desired horizontal position.
// this evenly distributes rounding errors across all images in this row.
$suggestedWidth= round($accumDesiredWidth - $accumWidth);
$finalImgWidth= (int) min($availableWidth, $suggestedWidth); // finalImgWidth may not exceed $availableWidth
$accumWidth+= $finalImgWidth;
$imgConf['file.']['width'] = $finalImgWidth;
$imgConf['file.']['height'] = round($desiredHeight);
// transfer info to the imageObject. Please note, that
$imgConf['file.']['height'] = round($equalHeight/$scale);
// other stuff will be calculated accordingly:
unset($imgConf['file.']['width']);
unset($imgConf['file.']['maxW']);
unset($imgConf['file.']['maxH']);
unset($imgConf['file.']['minW']);
(8-8/12)