Ask a Question related to Macromedia ColdFusion, Design and Development.
-
Andrew #1
Displaying images from a folder
I'm trying to display all the images in a particular folder.
I'm using this cfdirectory:
<cfset thisPath = "\\daytona\cflr\images\vehicle\" & #URL.v# & "\sm\">
<cfdirectory action="list" directory="#thisPath#" name="vehphoto">
Daytona is a local CF (Windows 2003) server, cflr is a share on that server.
I'm then using this to output the images:
<cfoutput query="vehphoto">
<img src="#thisPath##vehphoto.name#" width="98" alt="#rsFleet.MakeDesc#
#rsFleet.ModelDesc# #rsFleet.Type#">
</cfoutput
After a fair bit of tinkering with the server, I got this to work ... but
only in IE. Here's a snippet from View Source:
<img src="\\daytona\cflr\images\vehicle\2\sm\DSCN5.jpg" width="98"
alt="TVR">
In both Opera and Firefox, only the contents of the alt attribute is
displayed, as if the browser can't find the images.Is there something in IE
that allows it to display images, or are Opera and Firefox at fault here?
I must admit, I don't like using the \\server\share format, but can't see
another way of doing it. I'm not sure how it's going to be handled when I
move the site to a production server at an ISP. I would much prefer simply
linking to the images as:
<cfset image_src = "../images/vehicle/lg/#VehicleID#.jpg">
<cfset image_pth = ExpandPath(image_src)>
<img src="#image_src#" alt="#MakeDesc# #ModelDesc# #Type#" width="275"
height="146" />
but, of course, that's only suitable for single images, that I know the name
of. I need to output all images in a particular folder (as the folder name
will be the ID).
Am I missing something glaringly obvious? Any help *much* appreciated!
Andrew
Andrew Guest
-
Help displaying images
I am trying to display many pictures. I get all the file names in an array, cycle through the array creating image objects, then add them to the... -
Error Displaying Folder
New install of ubuntu v5.10 puts a hda1 icon on the desk-top. Error message is displayed while opening. Error window:Error displaying... -
displaying images
i am tying to display images dynamically on a product detail page based on a user selection on a page which displays a list of products. i am using... -
Displaying Images from Left to Right
Good evening folks, I was wondering if there is a way to output a series of images in a table so that they list out from left to right. ... -
ASP Displaying Images from within SQL DB
I've been searching and searching for this and there are lots of posts - but very few answers. I have a SQL2000 Database that has jpg images in a... -
blewis #2
Re: Displaying images from a folder
You may want to consider writing a script that actually gets and displays the
images. The UNC path works for IE images, but as you discovered, will not work
with other browsers. This is probably a bad way to do it. Instead, write a
special getImage script and use that as the image src. So the source may look
like:
<img src="getImage.cfm?img=\images\vehicle\2\sm\DSCN5.j pg" width="98"
alt="TVR">
Then in the getImage.cfm, use the CFCONTENT tag to get and output the image,
such as:
<CFCONTENT file="\\daytona\cflr\#img#" type="image/jpeg">
Bryan
blewis Guest
-
Andrew #3
Re: Displaying images from a folder
Hi Bryan
Thanks for the reply.
Really? I've not seen that documented anywhere. That would be remarkably> The UNC path works for IE images, but as you discovered, will not work
> with other browsers.
short-sighted of Macromedia then!
Ah, but that's the problem. I don't know the name of the image files, nor> This is probably a bad way to do it. Instead, write a
> special getImage script and use that as the image src. So the source may
> look
> like:
>
> <img src="getImage.cfm?img=\images\vehicle\2\sm\DSCN5.j pg" width="98"
> alt="TVR">
>
> Then in the getImage.cfm, use the CFCONTENT tag to get and output the
> image,
> such as:
>
> <CFCONTENT file="\\daytona\cflr\#img#" type="image/jpeg">
how many there are; I just know the name of the folder they will be in. This
is the stumbling block and it would seem that CFDIRECTORY is the only way to
get that list.
I believe the problem is in supplying the path to cfdirectory. Ideally, *the
image source* would be in the order of :
"../images/vehicle/sm/2/DSCN5.jpg"
Currently, it is:
"\\daytona\cflr\images\vehicle\2\sm\DSCN5.jpg"
After you mentioned CFCONTENT, I turned to my trusty CF5 WACK and studied
it. Adapting Ben's structure to get the list of images in a subfolder:
<cfset VehDir = GetDirectoryFromPath(GetCurrentTemplatePath()) & "2\sm\">
<cfdirectory directory="#VehDir#" action="list" filter="*.jpg"
name="GetVeh">
the image source is turned to:
"C:\Inetpub\wwwroot\LR\fleet\2\sm\DSCN5.jpg"
.... which, of course, doesn't show the images. I'm sure I'm missing
something simple ... can you or anyone else help.
<mumble>Be much easier in ASP ...</mumble>
Andrew Guest
-
Andrew #4
Re: Displaying images from a folder
I've sorted this ... and can't believe that I missed something so simple.
Just in case others were wondering, here's the result:
<cfset pthVehicle = GetDirectoryFromPath(GetCurrentTemplatePath()) & #URL.v#
& "\sm\">
<cfdirectory directory="#pthVehicle#" action="list" filter="*.jpg"
name="rsVehImage">
As expected, this will result in a listset comprising of:
"C:\Inetpub\wwwroot\LR\fleet\2\sm\DSCN1.jpg"
"C:\Inetpub\wwwroot\LR\fleet\2\sm\DSCN2.jpg"
....etc...
The crucial difference, and the crucial thing that I missed, is that the IMG
SRC still points to the relative folder, i.e. "../images/vehicle", *not* the
path passed to cfdirectory.
<cfoutput query="rsVehImage">
<img src="../images/vehicle/#URL.v#/sm/#rsVehImage.Name#" width="98"
alt="#rsFleet.MakeDesc#" />
</cfoutput>
<cfslap head = "hard">
Doh!
</cfslap>
Andrew Guest



Reply With Quote

