Low Variables and Assets Variable Type
Hi there, Low
Sorry to bother you, but I have a Low Variable set up as an Assets variable type, so that users can change template images, and I have a few questions.
First of all, I can get the image itself using
<img src="{exp:low_variables:parse var="sidebar_image"}">
So that bit's fine, and the image displays okay ... but then I'm not sure how I go about getting to the metadata that is stored within the Assets field -- like width and height, for instance. I'd like to add those values as attributes for the img tag, and I'd also like to use the title and alt text that the user has input.
Any ideas on how I might achieve that? I think there is something that just hasn't clicked properly ... I've tried a range of different code combinations, but can't get anything to output exactly right. Sometimes I get the image, for instance, but I also get code artefacts showing in the parsed template.
Next, and this might be even more tricky, is it possible to use an Assets variable type in an EE snippet? I've got the variable set for early parsing, but can't seem to get any output.
Once again, sorry for not being able to work this out myself ... but at the same time I very much hope you have time to help.
Cheers
Andrew
Replies
Low 22 Sep 2011 10:12
Hey Andrew,
You can get to all the different Assets variables by using {exp:low_variables:parse} as a tag pair. For example:
Also, you should be able to put the above code inside a snippet (early parsed var) and just use that in your templates.
Andrew Mac 22 Sep 2011 10:18
Hey Low
Thanks for the super-quick reply. I really appreciate it.
I've actually tried almost exactly that same code, and it didn't work for me ... so there must be some tiny little glitch in what I've been doing.
I'll go back and take a really careful look for typos in the code or other structural or environmental issues.
Thanks
Andrew
Low 22 Sep 2011 10:22
Are you using multiple instances of the {exp:low_variables:parse} tag, by any chance? Using a single tag before a tag pair can lead to unexpected results (and has been fixed in the upcoming version)...
Andrew Mac 22 Sep 2011 11:52
Aha, got it!
I've fallen for this before, a long time ago, so I probably should have thought about and checked straight away.
Anyway, the problem was that a curly quote got in my code, instead of a straight quote. I don't think if I typed it myself or if it came from a copy-and-paste job ... but that doesn't really matter.
It's fixed, and it's now working wonderfully well.
Cheers
Andrew
Low 22 Sep 2011 11:52
Excellent! :)