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

Images from external folder

Guest
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

I have a database that pulls an image from an image folder that is not part of the DB. The images are named #principal_ID#.png where the principal_id in the DB is a unique number. The corresponding images in the image folder are named after the individuals unique principal_Id so when the name is selected from a list trhe correct image is selected.

The code used to do this is as follow:

<cfquery name="profileImage" >
SELECT DISTINCT dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID
FROM (dbo.PPS_SCOS JOIN dbo.PPS_TRANSCRIPTS ON dbo.PPS_SCOS.SCO_ID = dbo.PPS_TRANSCRIPTS.SCO_ID)
JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID = dbo.PPS_PRINCIPALS.PRINCIPAL_ID
WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
AND dbo.PPS_PRINCIPALS.DISABLED IS NULL
</cfquery>

Output as follows:

<td width="22%" rowspan="5"><cfoutput query="profileimage">
<div align="center"><img src="images/#profileImage.PRINCIPAL_ID#.png" width="100" height="125"></div>
</cfoutput></td>

This works OK where there is an image. There are however a large number of names in the DB where we have no image and would like to be able to pull in a defualt image where there is none. The default image is called NAP.

I need to find a way for CF to pull in the default image where the principal_id does not have the users correct image.

Hope this makes sense. Any help appreciated.


TOPICS
Advanced techniques

Views

488

Translate

Translate

Report

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

correct answers 1 Correct answer

Engaged , Nov 13, 2006 Nov 13, 2006
Try something like this:-

Votes

Translate

Translate
Engaged ,
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

You can use the fileExists() function, but this is a little inefficient so if you are on Apache you can use mod_Rewrite to serve the default image if the named file does not exists!!

Votes

Translate

Translate

Report

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
Guest
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

Simon,

Thanks. I am not using Apache. 2. Will try fileExists though not sure how to code this. Any tips?

Thanks

Votes

Translate

Translate

Report

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
Engaged ,
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

Try something like this:-

Votes

Translate

Translate

Report

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
Guest
Nov 13, 2006 Nov 13, 2006

Copy link to clipboard

Copied

LATEST
Simon,

Excellent, that codes works perfect.

Thankyou very much.

Regards,

Nigel

Votes

Translate

Translate

Report

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
Documentation