I'm trying to get a image from Media Library without success. I've tried every implementation i've seen in this forum but none help. I'm new with Umbraco, but i'm almost sure that the error is not in the code.
I'm using version 4.
I've went to Media Library, create a new record, type Image and set the name to img1
Then created GetMedia.xslt as with the following code:
try this instead...
getMedia is trying to get a media file based on teh Media nodeID...
so instead of having a text field on your macro to type in teh media alias... change that to a media picker -- this will return a nodeID
in you xslt, you are already setting a variable, based on teh macro parameter... so you getMedia statement will look something like this...
[code]
[/code]
this is off the top of my head, so you may need to tweak some stuff... but mediaPicker is definitely going to be more flexible for you in the long run.
I'm trying to get the file using just the name, not the id. For what I've reading I the $currentPage/data [@alias=$imgAlias] should return the Id for the node.
Get Media Url by Name
Hi,
I'm trying to get a image from Media Library without success. I've tried every implementation i've seen in this forum but none help. I'm new with Umbraco, but i'm almost sure that the error is not in the code.
I'm using version 4.
I've went to Media Library, create a new record, type Image and set the name to img1
Then created GetMedia.xslt as with the following code:
[code]
]>
<>
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
[/code]
Created a Macro GetMedia with Parameter Alias=imgAlias, Name=imgAlias and Type=text
In my MasterPage template inserted the following code:
[code][/code]
I'm getting the error: [i]Error parsing XSLT System.Xml.Xsl.XslCompiledTransform
Value was either too large or too small for an Int32.[/i]
This happens because $currentPage/data [@alias=$imgAlias] does not return any value.
If I replace that by the file id, it works.
Can I use this macro in the MasterPage?
Am I uploandig the image correctly?
Can anyone help me?
Thanks
try this instead...
getMedia is trying to get a media file based on teh Media nodeID...
so instead of having a text field on your macro to type in teh media alias... change that to a media picker -- this will return a nodeID
in you xslt, you are already setting a variable, based on teh macro parameter... so you getMedia statement will look something like this...
[code]
[/code]
this is off the top of my head, so you may need to tweak some stuff... but mediaPicker is definitely going to be more flexible for you in the long run.
hope that helps.
Hi, thank you for your reply.
I'm trying to get the file using just the name, not the id. For what I've reading I the $currentPage/data [@alias=$imgAlias] should return the Id for the node.
Thanks
I'm trying to do something similar, but I've found no info at all on $imgAlias.
Is it possible to display an image in a macro or template, if you only have it's alias/name? (not the file name, and not the media ID)
My guess would be that it's not possible, since umbraco lets you create multiple images with the same alias, even within the same folder.
Please could anyone confirm/deny this?
Thanks
Hey all,
It works for me if I set the $ImgAlias to "propertyTypePicker" in the macro parameters... then i can choose what property to use
regards,
dave
is working on a reply...