Discussion:
[TYPO3-english] f:image f:uri.image giving different URLs
Jan Bednarik
2015-06-09 19:22:54 UTC
Permalink
Hi all,

I have a fluidcontent with FAL:

<flux:field.inline.fal name="images" label="Obrázky"
enabledControls="{dragdrop:true}" collapseAll="true" maxItems="9999"/>

And then I'm displaying them in for-each as:

<a href="{f:uri.image(src:image.uid,treatIdAsReference:true)}"
class="lightbox" rel="lightbox">
<f:image src="{image.uid}"
treatIdAsReference="true" width="100"/>
</a>

The problem is that the shown image is correct, but the URL in <a> tag
is wrong.

The image is correctly loaded where the "image.uid" belongs to
sys_file_reference and the reference points to the correct sys_file. The
uri.image however points to image where the uid is directly from sys_file.

Let's give example:

sys_file - uid 10 - identifier - A.jpg
sys_file_reference - uid 10 - uid_foreign - 20
sys_file - uid 20 - identifier - B.jpg

so when the image.uid is 10, result is

<a href="A.jpg"><img src="B.jpg"></a>

Any idea what I'm doing wrong?

Jan
Helmut Hummel
2015-06-12 14:42:20 UTC
Permalink
Post by Jan Bednarik
<flux:field.inline.fal name="images" label="Obrázky"
enabledControls="{dragdrop:true}" collapseAll="true" maxItems="9999"/>
<a href="{f:uri.image(src:image.uid,treatIdAsReference:true)}"
class="lightbox" rel="lightbox">
<f:image src="{image.uid}"
treatIdAsReference="true" width="100"/>
...
Post by Jan Bednarik
Any idea what I'm doing wrong?
I prefer to use "1" and "0" instead of "true" for boolean values.
Fluid treats all strings as bool TRUE if the string is not "flase"

However in your case, the real reason is, that in the shorthand sytax
"treatIdAsReference:true" means the key "treatIdAsReference" will
contain the value of the *variable* with the name "true". This is of
course not what you mean. Instead you should write the following:

{f:uri.image(src:image.uid,treatIdAsReference:'true')}

Or even *MUCH* better: Don't use "src" and "treatIdAsReference" *at all*

<a href="{f:uri.image(image:image)}"
class="lightbox"
rel="lightbox">
<f:image image="{image}"
width="100" />
</a>

Much shorter, less error prone!

Kind regards,
Helmut
--
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 CMS Active Contributor, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Helmut Hummel
2015-06-12 16:49:21 UTC
Permalink
Post by Helmut Hummel
Or even *MUCH* better: Don't use "src" and "treatIdAsReference" *at all*
I just published an article explaining that a bit more:

http://insight.helhum.io/post/121359113745/resources-the-image-view-helper-and-fal-in-typo3

HTH

Kind regards,
Helmut
--
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 CMS Active Contributor, TYPO3 Security Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Jan Bednarik
2015-06-13 12:14:27 UTC
Permalink
Hi Helmut,

thanks for answers. I tried to use image directly, but since this is
fluidcontent element, the images are retrieved like this:

<f:for each="{v:content.resources.fal(field: 'images')}" as="image">

and then there are actually arrays and not instances of image.

Meanwhile, I've resolved it like this:

<a href="{f:uri.page(pageUid:image.url)}" class="lightbox" rel="lightbox">
<f:image src="{image.uid}" treatIdAsReference="true" height="170"/>
</a>

and that seems to be working too.

Jan
Post by Helmut Hummel
Post by Helmut Hummel
Or even *MUCH* better: Don't use "src" and "treatIdAsReference" *at all*
http://insight.helhum.io/post/121359113745/resources-the-image-view-helper-and-fal-in-typo3
HTH
Kind regards,
Helmut
bernd wilke
2015-06-15 06:48:11 UTC
Permalink
Post by Jan Bednarik
Hi Helmut,
thanks for answers. I tried to use image directly, but since this is
<f:for each="{v:content.resources.fal(field: 'images')}" as="image">
and then there are actually arrays and not instances of image.
<a href="{f:uri.page(pageUid:image.url)}" class="lightbox" rel="lightbox">
<f:image src="{image.uid}" treatIdAsReference="true" height="170"/>
</a>
in fluidcontent you have access to all your defined variables without
the v:content.resources VH. so you should try:

<f:for each="{images}" as="image">
:
<a href="{f:uri.image(image:image)}" class="lightbox" rel="lightbox">
<f:image image="{image}" height="170"/>
</a>
:
</f:for>


bernd
--
http://www.pi-phi.de/cheatsheet.html
Jan Bednarik
2015-06-15 18:13:17 UTC
Permalink
Hi,

actually {images} was just a number (of relations) - using 6.2, latest
fluidcontent.

Jan
Post by bernd wilke
Post by Jan Bednarik
Hi Helmut,
thanks for answers. I tried to use image directly, but since this is
<f:for each="{v:content.resources.fal(field: 'images')}" as="image">
and then there are actually arrays and not instances of image.
<a href="{f:uri.page(pageUid:image.url)}" class="lightbox"
rel="lightbox">
<f:image src="{image.uid}" treatIdAsReference="true" height="170"/>
</a>
in fluidcontent you have access to all your defined variables without
<f:for each="{images}" as="image">
<a href="{f:uri.image(image:image)}" class="lightbox" rel="lightbox">
<f:image image="{image}" height="170"/>
</a>
</f:for>
bernd
Loading...