Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

Learn more about...

AspDotNetStorefront
DotFeed

How to check for image src value

I am using version 9.4.0, and have an xsl code below:
<xsl:value-of select="aspdnsf:LookupEntityImage(EntityID, $EntityName, 'medium', 0, $AltText)" disable-output-escaping="yes" />

Which will give me the syntax to display image like:
<img border="0" id="EntityPic33" name="litter-substrate-paper" class="actionelement" src="/App_Themes/skin_1/images/nopicture.gif" alt="Litter, Substrate, and Paper" />

Could any one please tell me how to check the image src so that I can skip displaying the image if the value of it is "nopicture.gif"?

Thank you for your time.

asked May 5, 2014 in MultiStore by locpham7 (645 points)

1 Answer

0 votes
 
Best answer

We do basically what you're after in one of the 'out of the box' XML packages - entity.gridwithprices.xml.config:

 

<xsl:variable name="EntityImageExists" select="not(contains($EntityImage, 'nopicture'))" />

 

You can use that to check if the entity has an image or not.  There's also an XSLT method called aspdnsf:InStr that checks to see if one string contains another.

 

answered May 5, 2014 by Vortx ScottS (13,500 points)
selected May 6, 2014 by locpham7
Thanks for your answer Scott. I have tried your solution and here are what I get:

1. I am using version 9.4.0 and can't find the variable "EntityImageExists" anywhere in the entity.gridwithprices.xml.config package.

2. I copied  and pasted your xsl syntax to the entity.xml.config package to see if it run, I got an error msg saying "unable to process request".

3. The XSLT method called aspdnsf:InStr, can you give me an example how to use it to check image source.

Thank you for your time.
Thanks Scott, I finally figured out how to apply your answer to my challenge. 
It was a big help and I greatly appreciate your insight.
Below is the codes, just in case anyone runs into the same problem:

<xsl:variable name="testing" select="aspdnsf:LookupEntityImage(EntityID, $EntityName, 'medium', 0)" />
                  <xsl:variable name="EntityImageExists" select="not(contains($testing, 'nopicture'))" />
                  
                  <xsl:if test="$EntityImageExists" >
                         image exist.......
                  </xsl:if>
                  <xsl:if test="not($EntityImageExists)" >
                         image not exist.......
                  </xsl:if>

 

...