I'm pretty new to umbraco but found the system pretty easy to use and have done alot in a short space of time. One difficulty I have come accross is displaying an image.
In the document type I have added an "upload" where an image is selected. In my XSLT I loop through the pages, this loop displays the other fields such as description or title. I am trying to display the image here.
Here is my XSLT for displaying my image, this displays nothing. The field "promothumbImage" is defined in the document type, as I said everything else is working fine.
<xsl:value-ofselect="promothumbImage"/>
Does anyone have any ideas as to where I am going wrong?
EDIT:
promothumbimage is defined in the document of type "upload"
<!-- The fun starts here --> <divclass="promoitems">
<xsl:for-eachselect="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']"> <divclass="promoitem">
you need the alias of the image, in my case "photo". In your case i think it will be "promothumbImage" (is that the alias for it?) so something like the following will work.
When you're using the upload property then you should be able to fetch the image by just writing out the value, which should hold the path.
Like this: <xsl:value-of select="promothumbImage" />. In order to write out an <img> tag to actually display the image you would need to write it like this:
<img src="{promothumImage}" />, which should render your image.
If you at some point need to render a image selected with a media picker you will need to use the GetMedia extension, to fetch the image. You can read more about that here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia (Look at the example for Umbraco 4.5 since that is the XML schema that is being used with 4.5+ Umbraco installations).
I'm very happy to hear that. You're very welcome. Please don't hesitate to ask about anything Umbraco related in here since it can probably save you a lot of frustration - you should also be aware that you can find many xslt extensions out of the box that can ease some tasks for you - simply just have a look at the wiki link I posted above.
And maybe at some point you can benefit from checking out the uComponents package, which is also filled with extension etc. to make our lifes even more easy :)
Displaying an image in the XSLT
I'm pretty new to umbraco but found the system pretty easy to use and have done alot in a short space of time. One difficulty I have come accross is displaying an image.
In the document type I have added an "upload" where an image is selected. In my XSLT I loop through the pages, this loop displays the other fields such as description or title. I am trying to display the image here.
Here is my XSLT for displaying my image, this displays nothing. The field "promothumbImage" is defined in the document type, as I said everything else is working fine.
Does anyone have any ideas as to where I am going wrong?
EDIT:
promothumbimage is defined in the document of type "upload"
Hi Louis,
You still need the img tag...here is a sample from one of my site which uses imagegen (fantastic package)
<img src="/ImageGen.ashx?image={current()/photo}&width=150&height=100&constrain=true" alt="{@nodeName}" />
you need the alias of the image, in my case "photo". In your case i think it will be "promothumbImage" (is that the alias for it?) so something like the following will work.
<img src="{promothumbImage}" alt="{@nodeName}" />
Hope this helps.
S
Hi Louis and welcome to our :)
When you're using the upload property then you should be able to fetch the image by just writing out the value, which should hold the path.
Like this: <xsl:value-of select="promothumbImage" />. In order to write out an <img> tag to actually display the image you would need to write it like this:
<img src="{promothumImage}" />, which should render your image.
If you at some point need to render a image selected with a media picker you will need to use the GetMedia extension, to fetch the image. You can read more about that here: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia (Look at the example for Umbraco 4.5 since that is the XML schema that is being used with 4.5+ Umbraco installations).
Hope this helps.
/Jan
YES YES YES YES YES!!!!!! thanks Jan!!!!! Worked great!!!!!! I've been banging my head for a long time on this!!!!
Hope you have a happy new year!
Louis
Hi Louis
I'm very happy to hear that. You're very welcome. Please don't hesitate to ask about anything Umbraco related in here since it can probably save you a lot of frustration - you should also be aware that you can find many xslt extensions out of the box that can ease some tasks for you - simply just have a look at the wiki link I posted above.
And maybe at some point you can benefit from checking out the uComponents package, which is also filled with extension etc. to make our lifes even more easy :)
...And a happy new year to you!
/Jan
is working on a reply...