I guess that this is a very basic question for some of you, so hope that you can help here. I have been searching the internet for tutorials and guides on how to use media picker in combination with xslt, but i seem to get it wrong.
1) I createt a property under one of my Documents Types -> I called it Media Item and alias mediaItem.
2) I created a xslt document and a macro and put in the following code:
I should also just be sure that you only create the macro in the creation of xslt file. You write: the point 3 that you create a macro. But is this not created in connection with the xslt file creation.
Yes, when i created the my Billed.xslt it also created the Billed macro. The Billed macro does not have any parameters.
I changed the code as you explained above, but unfortunately, nothing changed. I also tried to delete the image under my article and uploade a new image, but without luck.
My guess would be that you've found some XSLT for the old version of the XML schema - here's something that'll work with Umbraco 4.5 and later (just replace your existing <xsl:template match="/"> ... </xsl:template> with these two templates):
I am using Media Picker to select images in a collection. I want to access this collection for a slide show. I inherited code from another developer who was using File Upload to add pictures to the Collection of Images, this worked fine, except that we end up with a lot of images, and the images can't be easily shared. So I changed the File Upload to a Media Picker and no image was displayed. When I view page source the error is obvious.
Media Picker - how does it work
Hello,
I guess that this is a very basic question for some of you, so hope that you can help here. I have been searching the internet for tutorials and guides on how to use media picker in combination with xslt, but i seem to get it wrong.
1) I createt a property under one of my Documents Types -> I called it Media Item and alias mediaItem.
2) I created a xslt document and a macro and put in the following code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
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">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<xsl:variable name="mediaId" select="number($currentPage/data[@alias='mediaId'])" />
<xsl:if test="$mediaId > 0">
<xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
<xsl:if test="count($mediaNode/data) > 0 and string($mediaNode/data[@alias='umbracoFile']) != ''">
<img src="{$mediaNode/data[@alias='umbracoFile']}" alt="[image]" height="{$mediaNode/data[@alias='umbracoHeight']}" width="{$mediaNode/data[@alias='umbracoWidth']}" />
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
3) I created a macro called Billede.
4) I added the Macro to my template as follow: <umbraco:Macro Alias="Billede" runat="server"></umbraco:Macro><br>
I don't get it. How does it all fit together - can anyone please take a look, and tell me what is wrong.
Best Regards
Klaus
Hi Klaus,
I just took a look at your code. What the immediately just to see may be the problem is this line.
Try something like, hope it helps you
I should also just be sure that you only create the macro in the creation of xslt file. You write: the point 3 that you create a macro. But is this not created in connection with the xslt file creation.
Hope this can help to solve your question.
/Dennis
Hallo Dennis,
Yes, when i created the my Billed.xslt it also created the Billed macro. The Billed macro does not have any parameters.
I changed the code as you explained above, but unfortunately, nothing changed. I also tried to delete the image under my article and uploade a new image, but without luck.
Any suggestions?
/klaus
I guess that the mediaItem is the property of the Media Picker in my Document Types? Or how does it work?
/Klaus
Hi Klaus,
My guess would be that you've found some XSLT for the old version of the XML schema - here's something that'll work with Umbraco 4.5 and later (just replace your existing <xsl:template match="/"> ... </xsl:template> with these two templates):
/Chriztian
Hi agin Klaus,
I'll try to help as best I can.
I gotta hear it's just a media picker will print an image on the page you stand on the content tree.
If so, I think you can do it that way. Must just say I do not have much experience with this old xml schema in Umbraco.
/Dennis
Hello again,
I works with the new snippet Christian gave me - thanks a lot.
I just have one issue now. I shows two images of the same? Any idea why?
/Klaus
Okay my bad - i overwrite another xlts with the code you gave me - stupid idiot i am.
//Thanks alot for your help.
/Klaus
I am using Media Picker to select images in a collection. I want to access this collection for a slide show. I inherited code from another developer who was using File Upload to add pictures to the Collection of Images, this worked fine, except that we end up with a lot of images, and the images can't be easily shared. So I changed the File Upload to a Media Picker and no image was displayed. When I view page source the error is obvious.
I am using the following;
img src="{umbraco.library:GetMedia(picture,false)}"
And I get this
img src="/media/10580/picked2.jpg760250137819jpg"
When the image I want is this
img src="/media/10580/picked2.jpg"
Hi Lou,
You can use:
to get right to the path - it mandates that there is a picture picked in the Media Picker, otherwise it will fail (hard).
Feel free to start a separate thread if you have more questions - that way it's easier for everyone to find a single answer to a specific question.
/Chriztian
Thank You Chriztian, it works now.
is working on a reply...