[TYPO3-english] Get image data without actually showing the image
jochem nabuurs
jochem at roquin.nl
Wed Mar 17 10:33:22 CET 2010
jochem nabuurs wrote:
> jochem nabuurs wrote:
>> 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
>>
>>
>
> I've got an addition to the above:
> Within the CONTENT object, I use RAND() for selecting a random image.
> But when I view the result in the website, the image is only shown at
> random when refreshing with crtl + f5.
>
> I thought this was because the image is cached, so I modified the the
> code so the headerImage should not be cached:
>
> page.bodyTagCObject = COA_INT
> page.bodyTagCObject.10 < temp.headerImage.20
>
> I've also changed renderObj to a COA_INT but these changes haven't got
> any effect.
>
> Can anybody tell me why the random function is not working?
>
> Thanks in advance
Never mind:
temp.headerImage was a CONTENT object, so it is cached. Therefor the
output of this object is cached, and therefor also the result of the
rand function.
By changing the temp.headerImage to a COA_INT object with the CONTENT
object inside, the CONTENT object is not cached anymore and the rand
function is executed every time a refresh occurs...
Code example:
...
lib.headerImage = COA_INT
lib.headerImage.10 = CONTENT
lib.headerImage.10 {
...
}
...
page.234 < lib.headerImage
page.bodyTagCObject < lib.headerImage.20
...
Still wondering if there is a workaround for the page.234 thing...
More information about the TYPO3-english
mailing list