I'm struggling with this supposingly trivial condition. I would like umbraco to check if there is a Banner Image if not to use the standard instance. I'm using following choose condition.
<xsl:variable name = "imagePath" select="umbraco.library:GetMedia($articleImage, 0)/umbracoFile" /> <xsl:variable name = "articleBanner" select="concat(substring-before($imagePath, '.'), '_banner.jpg')" />
I'm checking if there is photo on the disk. Basically I'm using image cropper to produce _banner photo and then checking if it was produced that instance should be used otherwise it will do something else.
With the code above you should be able to dispaly the image from the page that you are on, if one is selected in a mediaPicker. Or is just take the no image. I hope this will work for you.
It displays the image but doesn't make the second condition fire. It shows when the banner photo is there but if there isn't one it doesnt show noimage.jpg.
I almost thought I'm finished. Is Chriztian's code choosing between noimage if there is no banner image and _banner if there is one? Currently it picks banner if there is one but shows nothing if isn't.
Technically, it writes the "noimage" as the default image (obviously /media/1058/noimage.jpg must exist) - then, if the $articleImage variable has content, it will find that media item, and if it has a "banner" crop, it will rewrite the img tag's src attribute to use the crop instead.
Can you maybe show how you're using it - maybe you forgot to include something?
Actually now it worked. It looks like it works in some instances but not in other. I must look around and see what's the difference between them. It might be come cashing issue or I didn't generate crops in some situations. Thanks for your help again.
Choosing photo instance
Hi
I'm struggling with this supposingly trivial condition. I would like umbraco to check if there is a Banner Image if not to use the standard instance. I'm using following choose condition.
<xsl:variable name = "imagePath" select="umbraco.library:GetMedia($articleImage, 0)/umbracoFile" /> <xsl:variable name = "articleBanner" select="concat(substring-before($imagePath, '.'), '_banner.jpg')" />
<xsl:choose>
<xsl:when test="$articleBanner != ''">
<img src="{$articleBanner}"/>
</xsl:when>
<xsl:otherwise>
<img src="/media/1058/noimage.jpg"/>
</xsl:otherwise>
</xsl:choose>
Any Ideas?
Thanks
Maciej
Hi Maciej,
Do you want to check for the physical image on disk (e.g.: "filename_banner.jpg") or just make sure that $articleImage has an image selected?
/Chriztian
Hi Chriztian
I'm checking if there is photo on the disk. Basically I'm using image cropper to produce _banner photo and then checking if it was produced that instance should be used otherwise it will do something else.
Regards
Maciej
Hi Maciej,
Will try to help you. I can´t see what you are using the _banner.jpg but probably just me,
Have you try someting like this:
With the code above you should be able to dispaly the image from the page that you are on, if one is selected in a mediaPicker. Or is just take the no image. I hope this will work for you.
/Dennis
Okay - if you're using the Image Cropper, you will have the crops in the XML - so you could do something like this:
/Chriztian
Thanks Dennis
It displays the image but doesn't make the second condition fire. It shows when the banner photo is there but if there isn't one it doesnt show noimage.jpg.
/Maciej
Okay Maciej,
I think that you should try what Chrizitan suggests in his post. He is super good at XSLT.
Many of us in this forum, also know him as Mr. XSLT :)
/Dennis
Thanks Chriztian
That's spot on. You trully live up to the expectations.
I will include you in my tonight's pray. :)
Many Thanks
Maciej
Wow - thanks to both of you — very kind :-)
/Chriztian
I almost thought I'm finished. Is Chriztian's code choosing between noimage if there is no banner image and _banner if there is one? Currently it picks banner if there is one but shows nothing if isn't.
/Maciej
Hi Maciej,
Technically, it writes the "noimage" as the default image (obviously /media/1058/noimage.jpg must exist) - then, if the $articleImage variable has content, it will find that media item, and if it has a "banner" crop, it will rewrite the img tag's src attribute to use the crop instead.
Can you maybe show how you're using it - maybe you forgot to include something?
/Chriztian
Actually now it worked. It looks like it works in some instances but not in other. I must look around and see what's the difference between them. It might be come cashing issue or I didn't generate crops in some situations. Thanks for your help again.
/Maciej
is working on a reply...