[TYPO3-english] Gifbuilder

StephenBungert stephenbungert at yahoo.de
Fri Oct 10 17:38:37 CEST 2008


Thanks both for your help. I think to get those problems fixed would mean
upgrading which we don't have time for. However I have a solution that
works.

Here is my new script:

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 1999-2004 Kasper Skaarhoj (kasper at typo3.com)
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt and important notices to the
license
*  from the author is found in LICENSE.txt distributed with these scripts.
*
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

function user_fmfV2ImageProcessor($paramArray, $conf) {
	$markerArray = $paramArray[0];
	$lConf = $paramArray[1];
    $pObj = &$conf['parentObj']; // make a reference to the parent-object
	$row = $pObj->local_cObj->data;
	
	$picWidthList		= '147';
	$picHeightList		= $picWidthList;
	$picWidthLatest		= '469';
	$picHeightLatest	= '314';
	$picFilePath		= 'uploads/pics/';
	$picBasePath		= 'fileadmin/templates/fmf/v2/images/';
	
	$imageNum = isset($lConf['imageCount']) ? $lConf['imageCount']:1;
	$imageNum = t3lib_div::intInRange($imageNum, 0, 100);
	$theImgCode = '';
	$imgs = t3lib_div::trimExplode(',', $row['image'], 1);
	$imgsCaptions = explode(chr(10), $row['imagecaption']);
	$imgsAltTexts = explode(chr(10), $row['imagealttext']);
	$imgsTitleTexts = explode(chr(10), $row['imagetitletext']);

	reset($imgs);

	$cc = 0;
	
	$whatToDisplay =
$pObj->cObj->data['pi_flexform']['data']['sDEF']['lDEF']['what_to_display']['vDEF'];
	
	if ($whatToDisplay == 'SINGLE') {
		// remove first img from the image array in single view if the TSvar
firstImageIsPreview is set
		if ((	(count($imgs) > 1 && $pObj->config['firstImageIsPreview']) ||
(count($imgs) >= 1 && $pObj->config['forceFirstImageIsPreview']))) {
			array_shift($imgs);
			array_shift($imgsCaptions);
			array_shift($imgsAltTexts);
			array_shift($imgsTitleTexts);
		}
		
		// get img array parts for single view pages
		if ($pObj->piVars[$pObj->config['singleViewPointerName']]) {
			$spage = $pObj->piVars[$pObj->config['singleViewPointerName']];
			$astart = $imageNum*$spage;
			$imgs = array_slice($imgs,$astart,$imageNum);
			$imgsCaptions = array_slice($imgsCaptions,$astart,$imageNum);
			$imgsAltTexts = array_slice($imgsAltTexts,$astart,$imageNum);
			$imgsTitleTexts = array_slice($imgsTitleTexts,$astart,$imageNum);
		}
		
		// Still to do...
		// SINGLE page articles don't have images in V2. May need to later handle
images for SINGLE if this changes.
	}
	
	if ($whatToDisplay == 'LIST' || $whatToDisplay == 'SEARCH') {
		while (list(, $val) = each($imgs)) {
			if ($cc == $imageNum) break;
			if ($val) {
				$lConf['image.']['file']							= $picBasePath . 'art_small.gif';
				$lConf['image.']['file.']['m.']['mask']				= $picBasePath .
'art_small_mask3.gif';
				$lConf['image.']['file.']['m.']['bgImg']			= $picFilePath . $val;
				$lConf['image.']['file.']['m.']['bgImg.']['width']	= $picWidthList .
'c';
				$lConf['image.']['file.']['m.']['bgImg.']['height']	= $picHeightList .
'c';
				$lConf['image.']['file.']['format']					= 'jpg';
				$lConf['image.']['file.']['quality']				= '90';
				$lConf['image.']['altText']							= $imgsAltTexts[$cc];
				$lConf['image.']['titleText']						= $imgsTitleTexts[$cc];
			}
			$theImgCode .= $pObj->local_cObj->IMAGE($lConf['image.']) .
$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']);
			$cc++;
			unset($imgs[0]);
		}
	} else if ($whatToDisplay == 'LATEST') {
		while (list(, $val) = each($imgs)) {
			if ($cc == $imageNum) break;
			if ($val) {
				$lConf['image.']['file']							= $picBasePath . 'art_large.jpg';
				$lConf['image.']['file.']['m.']['mask']				= $picBasePath . 
'article_large_mask3.png';
				$lConf['image.']['file.']['m.']['bgImg']			= $picFilePath . $val;
				$lConf['image.']['file.']['m.']['bgImg.']['width']	= $picWidthLatest .
'c';
				$lConf['image.']['file.']['m.']['bgImg.']['height']	= $picHeightLatest .
'c';
				$lConf['image.']['file.']['format']					= 'jpg';
				$lConf['image.']['file.']['quality']				= '90';
				$lConf['image.']['altText']							= $imgsAltTexts[$cc];
				$lConf['image.']['titleText']						= $imgsTitleTexts[$cc];
				
				
				$lConf['image.']['altText']		= $imgsAltTexts[$cc];
				$lConf['image.']['titleText']	= $imgsTitleTexts[$cc];
			}
			$theImgCode .= $pObj->local_cObj->IMAGE($lConf['image.']) .
$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']);
			$cc++;
			unset($imgs[0]);
		}
	}
	
	$markerArray['###NEWS_IMAGE###'] = '';
	
	if ($cc) {
		$markerArray['###NEWS_IMAGE###'] =
$pObj->local_cObj->wrap(trim($theImgCode), $lConf['imageWrapIfAny']);
	} else {
		$markerArray['###NEWS_IMAGE###'] =
$pObj->local_cObj->stdWrap($markerArray['###NEWS_IMAGE###'],$lConf['image.']['noImage_stdWrap.']);
	}
	
	return $markerArray;
}
?>


It doesn't use GIFBUILDER so the image quality is great. The only problem I
hhad was that the article image (the background image now, was scaled to fit
the foreground image - the border. After experimenting I have found how to
scale the background image (the articles image) so that it doesn't get
squashed to the size of the imageResource.

See the above code to see how. It is not finished. I need to test it with
articles with multiple images and see what would happen, as we only want one
image in the list view.

Thanks again!

-----
-- 
Stephen Bungert
-- 
View this message in context: http://www.nabble.com/-TYPO3-english--Gifbuilder-tp19898191p19920727.html
Sent from the TYPO3 English mailing list archive at Nabble.com.



More information about the TYPO3-english mailing list