Okay so it turns out I'm being an idiot and in my second example I'm trying to output a media item that on further inspection doesn't actually have a file uploaded for it in the Media section! Doh. So images do seem to work -when an image has been actually uploaded :)
Right and the second problem was fixed by going in to my media types where I had created a new type called Flash Movie. I saved this, then saved my video in the Media section, et viola - it works.
Thanks @quixltd for taking the time to have a look. Thankfully it seems to be working fine, and maybe this discussion will help others with the same issues I had!
umbraco.library:GetMedia in v4.1?
using umbraco.library:GetMedia in xslt in umbraco 4.1 doesn't return anything.
Can anybody help out what to use/do?
/Rasmus
i had the same issue when the beta first came out... and really... got no response from anyone... and no solution either.
sorry
If it seems like a bug then it should be logged on Codeplex
Has this been logged on codeplex? A search in the issue tracker for getmedia returns nothing...
Good heavens, if it isn't there... go add it!
cheers,
doug.
Yes sir! :) I've confirmed this is a bug for me in v4.1 beta 2. Go vote!
http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=27109
Crap, this is stopping me updating a few packages to 4.1.
voted on codeplex
It's been fixed in the nightlies for a while, I think, just waiting for the RC...
It seems that is still doesn't work in 4.1RC. Calling this:
results in this output:
node:No media is maching '1341'
1341 is the id of a flash file that definitely exists and can be browsed through the Media section. Anyone else getting this?
I get this if I point it to an image file:
node:/media/244/colour change.jpg1074976586198jpg
so I gues using the proper umbracoFile syntax will work.
Hmm, I dunno. Check this out, I'm trying to output an image - the id is stored as the image attribute of my eventNode:
Gives output of:
How can I now display the image if umbracoFile is empty?
This works for me in 4.1RC when hard coding the property names mainImage and altText:
<xsl:variable name="picFile" select="$currentPage/mainImage"/>
<xsl:variable name="altText" select="$currentPage/altText"/>
<xsl:if test="$picFile != ''">
<img id="mainImage" src="{umbraco.library:GetMedia($picFile, 'false')/umbracoFile}" >
<xsl:attribute name="alt">
<xsl:value-of select="$altText"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="umbraco.library:GetMedia($picFile, 'false')/umbracoWidth" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="umbraco.library:GetMedia($picFile, 'false')/umbracoHeight" />
</xsl:attribute>
</img>
</xsl:if>
However I can't replace the $currentPage/mainImage with $currentPage/$picFile since the $ causes an error, will investigate further
HTH
Hi @quixltd,
Okay so it turns out I'm being an idiot and in my second example I'm trying to output a media item that on further inspection doesn't actually have a file uploaded for it in the Media section! Doh. So images do seem to work -when an image has been actually uploaded :)
Right and the second problem was fixed by going in to my media types where I had created a new type called Flash Movie. I saved this, then saved my video in the Media section, et viola - it works.
Thanks @quixltd for taking the time to have a look. Thankfully it seems to be working fine, and maybe this discussion will help others with the same issues I had!
Cheers,
David
An update for Umbraco 4.5!!!!!
While the code I posted earlier works for 4.1RC it doesn't for for 4.5, with thnks to Lee Kelleher, the updated version which works in 4.5 is:
<xsl:variable name="picFile" select="$currentPage/mainImage"/>
<xsl:variable name="altText" select="$currentPage/altText"/>
<xsl:if test="$picFile != ''">
<img id="mainImage" src="{umbraco.library:GetMedia($picFile, 'false')/Image/umbracoFile}" >
<xsl:attribute name="alt">
<xsl:value-of select="$altText"/>
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="umbraco.library:GetMedia($picFile, 'false')/Image/umbracoWidth" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="umbraco.library:GetMedia($picFile, 'false')/Image/umbracoHeight" />
</xsl:attribute>
</img>
</xsl:if>
The only difference is the addition of /Image in front of /umbracoFile to become /Image/umbracoFile
This also works with the other syntax of:
img src="{umbraco.library:GetMedia($picFile, 'false')/Image/umbracoFile}" width=etc.
Hope this helps spme people
Tom
yes, i learned earlier today that the /Image is very important :)
is working on a reply...