Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfif not exists

New Here ,
Aug 14, 2008 Aug 14, 2008
Hi.what would be the code look like when I want to say type no image when there is no image on the images folder?
this one didnt work:

<cfif isDefined("getBrands.cat_level2_image")><img src="#imagePath#images/logoImages/#getBrands.cat_level2_image#" /></a><cfelse>No Image</cfif>
TOPICS
Advanced techniques
434
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 14, 2008 Aug 14, 2008
I found my mistake:

<CFIF #getBrands.cat_level2_image# EQ "">
<img src="#imagePath#images/logoImages/#getBrands.cat_level2_image#" width="60" height="40" border="0" alt="#getBrands.cat_level2_name#" hspace="2" /></a><cfelse>No Image Available </cfif>

🙂
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 14, 2008 Aug 14, 2008
LATEST
a few suggestions:

1) drop the # inside the <cfif ...> - no need for them there.
2) better checking may be <cfif len(trim(getBrands.cat_level2_image))>
3) you may also want to check that the image file exists in that folder:
<cfif len(trim(getBrands.cat_level2_image)) AND
fileexists(expandpath('#imagePath#images/logoImages/#getBrands.cat_level2_image#'))>
- this way you won;t get the broken image/red cross icon if the redord
for the image in your db exists but the actual image in the folder has
been deleted...
4) alternative to #3 is adding an onError event to the <img> tag with a
simple js changing the image source to some generic "No Image Available"
image: <img src="..." ... onError="this.src='your_no_image_available.jpg';">

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources