Developer forum

Forum » Ecommerce - Standard features » Check if an image exist

Check if an image exist

Per Ljung
Reply
Hi!

I have a assigned 2-6 images for a product and added custom image patterns, but as the number of images can vary I only want to display image patterns  that really have an attached image. I'm defining the patterns in the product catalog module and that the product images will reside in Billeder/Products and e.g. if there's not an image 45454_Image2_Large.jpg in that folder I don't want to display that tag, now it's an empty image if the jpeg file don't exist.

Is this possible?

Best regards,
P

Replies

 
Merethe Nielsen
Reply

Hi

What version do you use?
Can you attach an image of your paragraph settings and maybe your template?


Kind regards,
Merethe
 
Per Ljung
Reply
Hi!

Here is my code:
<xsl:if test="Ecom.Product.Image2Large.Clean != ''">

            <a>
              <xsl:attribute name="href">
                <xsl:value-of select="Ecom.Product.Image2Large.Clean" disable-output-escaping="yes"/>
              </xsl:attribute>

              <img
                  height="64" width="60" style="width: 60px; height: 54px; border: 0px;" >
                <xsl:attribute name="src">
                  <xsl:value-of select="Ecom.Product.Image2XSmall.Clean" disable-output-escaping="yes"/>
                </xsl:attribute>

                <xsl:attribute name="alt">
                  <xsl:value-of select="Ecom.Product.Name" disable-output-escaping="yes"/>
                </xsl:attribute>
              </img>
              
            </a>

          </xsl:if>


/Per
paragraph.gif
 
Vladimir
Reply
Hi Per!

I hope that can help you:)
In global settings you can set the img that will shown if pattern img is absent
"/Globalsettings/Ecom/Picture/NoPicture/" & Pattern
for example, in your case:
"/Globalsettings/Ecom/Picture/NoPicture/2Large"  -> "Billeder/NoPicture/x.jpg"
"/Globalsettings/Ecom/Picture/NoPicture/2XSmall"   -> "Billeder/NoPicture/x.jpg"
and so on...
So you can always determine is pattern img exist or not.

Best regards,
Vladimir




 
Per Ljung
Reply

Hi!

But I can only find settings for the patterns Small, Medium and Large, not the patterns of my own. There is a field to type in pattern, but no place to set the image if an image with that pattern doesn't exist.

Best regards,
Per
 
Vladimir
Reply
Do you have access to GlobalSetting.asph file?
If no, let's I self create these setting for you (I need to know address)

Best regards,
Vladimir

 
Per Ljung
Reply

I think so, I have full access to the solution, it's a custom solution. Just tell me where this file is placed.

/Per
 
Vladimir
Reply
Ok,  Files/GlobalSettings.aspx :)
 
Per Ljung
Reply

Hi!

I found it, but still a problem, my patterns are

2XSmall
3XSmall
4XSmall
5XSmall

But it seems like starting a node with a number is not valid xml. When I added these settings, the whole admin page became white with no content.

/Per
 
Per Ljung
Reply

Do you have an email?
 
Vladimir
Reply
hm.. you are right, xml node can't start with a number...  this was the most right way I think...
Well... another way extend xslt with c# code... but it is better not to do so...
 
Per Ljung
Reply
Hi! I think I can solve it in another way. But how do you write the xml code? I have tried this:
 <Picture>
      <NoPicture>
        <Medium>
        </Medium>
        <Large_path>
        </Large_path>
        <Large>
        </Large>
        <Small_path>
        </Small_path>
        <Medium_path>
        </Medium_path>
        <Small>
        </Small>

       
        <Img2_XSmall></Img2_XSmall>
        <Img3_XSmall></Img3_XSmall>
        <Img4_XSmall></Img4_XSmall>
        <Img5_XSmall></Img5_XSmall>

        <Img2_XSmall_path></Img2_XSmall_path>
        <Img3_XSmall_path></Img3_XSmall_path>
        <Img4_XSmall_path></Img4_XSmall_path>
        <Img5_XSmall_path></Img5_XSmall_path>
        
        </NoPicture>
 
Vladimir
Reply
As I understand you change your pattern prefix to Img2_XSmall, Img3_XSmall etc?
In that case your xml should be, for example:
<Picture>
     <NoPicture>
       <Medium>
       </Medium>
       <Large_path>
       </Large_path>
       <Large>
       </Large>
       <Small_path>
       </Small_path>
       <Medium_path>
       </Medium_path>
       <Small>
       </Small> 
       
       <Img2_XSmall>Billeder/NoPicture/x.jpg</Img2_XSmall>
       <Img3_XSmall>Billeder/NoPicture/x.jpg</Img3_XSmall>
       <Img4_XSmall>Billeder/NoPicture/x.jpg</Img4_XSmall>
       <Img5_XSmall>Billeder/NoPicture/x.jpg</Img5_XSmall>
        
       </NoPicture>


ps: don't forget to create this picture of course: /Files/Billeder/NoPicture/x.jpg
 
Per Ljung
Reply

Hi again!

My pattern is {productnumber}_Img2_XSmall.jpg, how do write this in GlobalSettings.aspx?

Best regards,
P
 
Per Ljung
Reply

Hi!

I'm not getting this to work, any ideas how to write? I asked the support too, but they referred me back to the forum because it was a developer issue. The solution is viking.net.

Best regards,
Per

 
Vladimir
Reply
Hi Per!
No no, I talked about the values in left column - so to write them in GlobalSettings they should be started with letters like (Img2_XSmall, Img3_XSmall etx)

Best regards,
Vladimir


 
Per Ljung
Reply

Hi again!

Yes I know, I've tried this and many other variants, but for some reason I can't make it work. No matter how I write I only get the path to the non existent pattern image file. I've looked in the template xml output and the a path to the "no-image"-file is missing.

Can you please take a look in the solution to see what's wrong, I gave you the solution name in a previous forum post.

If you do this

Best regards,
Per 

 
Vladimir
Reply
Per, I open viking.net - but this is just static html page?
 
Per Ljung
Reply

Oh, sorry, I meant viking.net.dynamicweb.se. Can you go to admin and check?

Best regards,
Per
 
Vladimir
Reply
Hi Per,
it seems I found decision
1) paths in globalsetting should be without  /files/, just: Billeder/no-image.gif
2) tags for this case should be ended with .Default.Clean  postfix (instead of .Clean)

Best regards,
Vladimir

 

You must be logged in to post in the forum