I have been trying all night to succesfully show an image from my Media store in a XSLT file I am building. I was to pass in the Media ID and then return the image URL.
If I do this: <xsl:value-of select="umbraco.library:GetMedia(1119, 'false')"/>
It returns this : ~/media/64/serviceimage1.jpg125818285jpg
Which is not quite right.
After looking around for the answer on how to return the real URL I changed it to this:
What version of Umbraco are you using? It looks like you're using the old xslt syntax. Try this, which should work with the new xml format that Umbraco uses:
I'm not sure what could be causing this. Are you running your site in IIS at the moment? Or just hitting F5 in Visual Studio? I'm clutching at straws ;)
Show image from Media in XSLT
Hi All
I have been trying all night to succesfully show an image from my Media store in a XSLT file I am building. I was to pass in the Media ID and then return the image URL.
If I do this: <xsl:value-of select="umbraco.library:GetMedia(1119, 'false')"/>
It returns this : ~/media/64/serviceimage1.jpg125818285jpg
Which is not quite right.
After looking around for the answer on how to return the real URL I changed it to this:
<xsl:value-of select="umbraco.library:GetMedia(1119,'false')/data [@alias='umbracoFile']"/>
It keeps returning nothing!
I have tried changing it to return width and height but it still returns nothing.
Any ideas ?
Hi Michael,
What version of Umbraco are you using? It looks like you're using the old xslt syntax. Try this, which should work with the new xml format that Umbraco uses:
<xsl:value-of select="umbraco.library:GetMedia(1119,'false')/umbracoFile"/>
Cheers,
David
Hi David
Thank you for that.
I am using version 4.7.1.1
Your fix above is now returning something which looks more like a proper URL. I am now getting: ~/media/64/serviceimage1.jpg
I just did the following:
<xsl:variable name="url" select="umbraco.library:GetMedia(1119,'false')/umbracoFile"/>
<img src="{$url}" />
And it throws an error!
The relative virtual path '="' is not allowed here
Any ideas?
I have done the following to remove the ~
<xsl:variable name="url" select="translate(umbraco.library:GetMedia(serviceThumbnailImage,'false')/umbracoFile, '~', '')"/>
Surely I am working around the issue here though ? Whats the correct way of doing it ?
Thanks!
Probably not much help, but it looks to me like you are doing it correctly. I haven't seen that tilde issue before. I'm using the following:
I've also tried it like this:
And the output for both is
Which is as expected, i.e. without the tilde.
I'm not sure what could be causing this. Are you running your site in IIS at the moment? Or just hitting F5 in Visual Studio? I'm clutching at straws ;)
David
Its running under IIS...
Thanks for your help. I seem to have a habit at attracting issues no one else has at the moment :D
Anyway this workaround should get me moving on but if anyone else has any idea then please le me know.
Thanks for your help David
is working on a reply...