I'm trying to show an image chosen from a currentMedia parameter (called imageParam) in a Marco. I try to do it like the code below, but I can't get my ID. The 'imageParam' contains all the information, and if I try to get only the ID I get the whole thing or nothing. What am I doing wrong?
Try this code, this should print out the image that you choose as the param when you add the marco to the template. I have added so it write an alt tag with the name of the image and added width and height of the image too.
There is something I don't understand, I totally understand this '/macro/imageParam/Image/@id' but when I want to 'print' this on the screen in a textbox like below, I just get the rest of the HTML from my page in the box. Why is this? I thought it was because '/macro/imageParam/Image/@id' returned nothing but appearently I was wrong (becaus your code does work).
Get ID of currentmedia image
Hello,
I'm trying to show an image chosen from a currentMedia parameter (called imageParam) in a Marco. I try to do it like the code below, but I can't get my ID. The 'imageParam' contains all the information, and if I try to get only the ID I get the whole thing or nothing. What am I doing wrong?
The textbox gives me:
<imageParam><Image id="1918" version="6ff935c2-7688-436e-965e-c1383eff557b" parentID="1327" level="2" writerID="0" nodeType="1032" template="0" sortOrder="0" createDate="2014-07-25T20:16:25" updateDate="2014-07-25T20:16:28" nodeName="xxxxxxxxx" urlName="xxxxxxxx" writerName="Robin" nodeTypeAlias="Image" path="-1,1327,1918"><umbracoFile>/media/33144/xxxxxxxxx.jpg</umbracoFile><umbracoWidth>3400</umbracoWidth><umbracoHeight>834</umbracoHeight><umbracoBytes>348763</umbracoBytes><umbracoExtension>jpg</umbracoExtension></Image></imageParam>
It's the '1918' I need, what is also in my macro:
<umbraco:Macro imageParam="1918" Alias="xxxxxxxx" runat="server"></umbraco:Macro>
Robin
Hi Robin,
Try this code, this should print out the image that you choose as the param when you add the marco to the template. I have added so it write an alt tag with the name of the image and added width and height of the image too.
Hope this helps,
/Dennis
Thanks a lot :)
I was looking it to far I gues.
There is something I don't understand, I totally understand this '/macro/imageParam/Image/@id' but when I want to 'print' this on the screen in a textbox like below, I just get the rest of the HTML from my page in the box. Why is this? I thought it was because '/macro/imageParam/Image/@id' returned nothing but appearently I was wrong (becaus your code does work).
Robin
is working on a reply...