Hi, I'm building a set of template/xslt where I would like to display general images (like logos, layout images etc.) took from media in order to give the user the chance tu change them without manually put the file on the webserver.
I've two problems:
- I'm not able to take the media using alias. I used this command and it works src="{umbraco.library:GetMedia(1096, false())/data[@alias='umbracoFile']}" but i would like to use something like src="{umbraco.library:GetMedia('logo', false())/data[@alias='umbracoFile']}".
- I'm not able to do the same thing in templates. I've to create a macro that return the correct path or I can do something inline?
Please note that data[@alias] is from "the old (or legacy) XML schema" (search for it). After Umbraco 4.5 (I think) we got a much improved and simpler XML schema to work with...
I don't want the user to specify the logo in every page. I would like to get the file from the media library that has the alias 'logo', not the one choosed in the logo param of the page.
@Chriztian: I used the legacy schema to recycle old xslts, I would like to upgrade them in a second time.
Get media by alias in xslt and template
Hi, I'm building a set of template/xslt where I would like to display general images (like logos, layout images etc.) took from media in order to give the user the chance tu change them without manually put the file on the webserver.
I've two problems:
- I'm not able to take the media using alias. I used this command and it works src="{umbraco.library:GetMedia(1096, false())/data[@alias='umbracoFile']}" but i would like to use something like src="{umbraco.library:GetMedia('logo', false())/data[@alias='umbracoFile']}".
- I'm not able to do the same thing in templates. I've to create a macro that return the correct path or I can do something inline?
Thanks in advance.
Hi Stevie,
You should be able to grab by alias using the data[@alias] syntax:
Please note that data[@alias] is from "the old (or legacy) XML schema" (search for it). After Umbraco 4.5 (I think) we got a much improved and simpler XML schema to work with...
/Chriztian
Hi Stevie,
In your xslt add a variable something like "mediaPicker"
and make a test to see it ever a file is choose from the media section
Sorry just noticed Chriztian's reply now while replying.
I don't want the user to specify the logo in every page. I would like to get the file from the media library that has the alias 'logo', not the one choosed in the logo param of the page.
@Chriztian: I used the legacy schema to recycle old xslts, I would like to upgrade them in a second time.
Aha - different problem, I see...
Well, then you need to grab the containing folder first - something like this:
Downside is you have to get all media if you cannot confine the images to a specific folder...
/Chriztian
is working on a reply...