[TYPO3-english] Get image data without actually showing the image

jochem nabuurs jochem at roquin.nl
Wed Mar 17 09:08:49 CET 2010


Hi list,

I've created the following code for generating an image with a mask onto 
it, to use as a background for a website.

// Fetch one random image from border column,
// apply a mask onto it, and use the url in the body tag
//
// In order for the code below to work, you need to set the following 
      // settings inside local_conf.php or change them through the 
installtool
// $TYPO3_CONF_VARS['GFX']['gdlib_png'] = '1';
// $TYPO3_CONF_VARS['GFX']['gdlib_2'] = '1';
// $TYPO3_CONF_VARS['GFX']['png_truecolor'] = '1';
// ---------------------------------------------------------------------

temp.headerImage = CONTENT
temp.headerImage {
	
	// Fetch a random image from the database
	table= tt_content
	select {
		pidInList = 2
         max = 1
		where = CType='image'
         andWhere (
             colPos=3 AND
             image!=''
         )
		orderBy = rand()
	}
	
	// Generate a new image from the old one,
	// with a nice green gradient on top of it.
	renderObj = COA
	renderObj {
	
		// generate the image
		10 = IMAGE
		10 {
			params = style="display:none;"
		
			file = GIFBUILDER
		    file {
				XY = 1000, 750
				format = jpg
				quality = 100
		
		
				// get the original image
				10 = IMAGE
				10 {
					file {
		    			import = uploads/pics/
				    	import.field = image
				    	width = 1000
				    	height = 750
					}
		           	offset = 0,0
				}
	
			
				15 = IMAGE
				15 {
					offset = 0,0
					file = fileadmin/images/foto.png
					file {
						width = 1000
						height = 750
					}
				}
		    }
		}
		
		// Create the bodytag contents
		// With the TSFE:lastImageInfo object,
		// you've got access to the image data
		// Don't know exactly how this works.
		20 = TEXT
		20.dataWrap = <body id="home" style="background-image: 
url({TSFE:lastImageInfo|3});">
		20.insertData = 1
	}
}


page.234 < temp.headerImage

page.bodyTagCObject = TEXT
page.bodyTagCObject < temp.headerImage.20


The above works perfect, but the "page.234" part outputs an image tag in 
the HTML code, which is not what i want. I've partially solved this with 
setting params = style="display:none;"  so the image isn't displayed.

I'd like to remove the "page.234 < .." part but then the image object 
isn't available (or something like that) and with it, the lastImageInfo 
data.

What I'd like to know is how to access the lastImageInfo object of the 
generated image, without having to output the actual image as a HTML 
element.

Thanks in advance,

Jochem Nabuurs




More information about the TYPO3-english mailing list