Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Insert tag {{picture::}} with a UUID reference starting with '}' #8644

Closed
arno1979 opened this issue Feb 10, 2017 · 4 comments
Closed

Insert tag {{picture::}} with a UUID reference starting with '}' #8644

arno1979 opened this issue Feb 10, 2017 · 4 comments

Comments

@arno1979
Copy link

Hey,

I just came across a mean little but when using the insert tag for pictures.
In my template I had a line like this

{{picture::<?php echo $film->image;?>?size=3&template=picture_default}}

where $film->image has a UUID value from a filepicker field.
According to the Contao docs I would be able to use the insert tag with a UUID just like I did in the code quoted above:

This tag will be replaced with an image and various image sources depending on your image size preferences and if the size parameter is a valid ID (replace * with the database ID, UUID or a file system path)

This all worked fine until suddenly – after uploading a new image and inserting it in my content element – instead of the new image I see the code for the insert tag in the frontend.
I quickly found the problem: The UUID of the image looked like this:

}�³�ï��æ¯�tÔ5�^¹

The significant character being the }. This causes the insert tag to not work correctly.

I am not sure what to do about it though. I don't know if the insert tag could be modified to take into account these occurences or if it would be possible to change the way the UUID is generated and prevent it from containing these characters. But as the UUID is a binary field I think that would be rather difficult.

@fritzmg
Copy link
Contributor

fritzmg commented Feb 10, 2017

You need to use

 \StringUtil::binToUuid(…)

e.g.

{{picture::<?= \StringUtil::binToUuid($film->image) ?>?size=3&template=picture_default}}

@arno1979
Copy link
Author

arno1979 commented Feb 10, 2017

Ah, great! Thanks! I knew about the StringUtil but didn't think to use it in my case because throwing the binary code at the insert tag worked in almost all cases.
Maybe it would be best (if possible) to throw an error message in the insert tag when using a binary value instead of a stringified UUID?

@fritzmg
Copy link
Contributor

fritzmg commented Feb 10, 2017

That won't be possible, since in your particular case the insert tag isn't even detected as an insert tag ;).

@arno1979
Copy link
Author

Yeah, that's what I thought. Thanks anyways for your help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants