I've been meaning to build something like this for a little while, so I took the base code here and built it out into a serviceable little image browser for a web site. I have packaged the whole thing into a zip and built a demo site for browsing here:

http://www.rkurup.com/dev/viewer/

You can get the whole thing here:

http://www.rkurup.com/dev/viewer/viewer.zip

I re-built the app in Fusebox 3. The core file for CF 5/MX is contained in the archive. cfx_image is not included in the archive, you can get it from Jukka Manner's Web site:

http://www.kolumbus.fi/jukka.manner/

The application is now frames-based with separate windows for folders and files. The file listings show thumbnails, names, sizes of the originals, and modification date.

One minor bug- the first time you click on a folder, cfx_image will build the thumbnails but not display them. click again to view the thumbnails. I'll sort that out another day.

Rob

>Here's something I wrote awhile back. It's not pretty
>but does the job.
>You'll need cfx_image.
>
>After you fix it up send it back :)
>
><!--- index.cfm --->
><html><head>
> <title>Gallery</title>
><script language="_javascript_">
><!--
> function openWin( windowURL, windowName,
>windowFeatures ) {
> return window.open( windowURL, windowName,
>windowFeatures ) ;
> }
>// -->
></script>
></head>
>
><body>
><cfparam Name="thePath" Default="">
><cfset rootdir = "/photos/">
>
><cfset isHomePage = false>
><cfif not isDefined("pinfo")>
> <cfset isHomePage = true>
> <cfset pinfo = rootdir>
></cfif>
>
>
><cfif IsDefined("Image")>
> <cfoutput><!--- Display Image here --->
> <img src=""> > </cfoutput>
> <cfabort>
></cfif>
>
><!--- Display Thumbnails --->
><cfif isHomePage>
> <table width="640" border="0" cellpadding="2"
>cellspacing="4">
> <tr>
> <td align="center" style="font-size:large;
>text-align:center; color:0000CC">Photo Album</td>
> </tr>
> <tr>
> <td>
>   <cfmodule template="viewer.cfm"
> thePath="#thePath#"
> rootdir="#rootdir#"
> pinfo="#pinfo#">  
> </td>
> </tr>
> </table>
><cfelse>
>  <cfmodule template="viewer.cfm"
> thePath="#thePath#"
> rootdir="#rootdir#"
> pinfo="#pinfo#">  
></cfif>
></body>
></html>
><!--- // index.cfm --->
>
><!---  viewer.cfm --->
><cfset basepath = "C:\CFusionMX\wwwroot">
><cfset reload = 0>
><cfdirectory action=""> > directory="#basepath##Replace(attributes.pinfo, "/",
>"\", "all")#"
> name="mydirectory"
> sort="name">
><table cellspacing="8" cellpadding="8">
><tr>
><cfset thecount=1>
><cfoutput query="mydirectory"><!--- this is so
>sub-folders show above images --->
> <cfif ListFindNoCase(type, "dir")>
> <td colspan="4">
> <cfif ListFindNoCase(name, "..")>
> <cfset dirname = "Home">
> <cfelse>
> <cfset dirname = name>
> </cfif>
> <cfif not ListFindNoCase(name, ".") and not
>ListFindNoCase(name, "..")>
> <cfif dirname is not "originals">
> <cfif listLen(dirname, "_") is 2><!--- Name the
>folders in sort order : 01_January, 02_February etc.
>then remove the number and _ --->
> <cfset showname = listGetAt(dirname, 2, "_")>
> <cfelse>
> <cfset showname = dirname>
> </cfif>
> <a
>href=""> > </cfif>
> </cfif>
> </td>
> </tr>
> <tr>
> </cfif>
></cfoutput>
><cfoutput query="mydirectory">
> <cfif not ListFindNoCase(Type, "Dir")>
> <cfif
>listContainsNoCase(QuotedValueList(mydirectory.name),
>"thumb_#name#")>
> <td width="25%">
> <a
>href=""> >"thumb_", "")#">
> <img src=""> > <br>#ReplaceNoCase(Name, ".jpg", "")#<br>
> </td>
> <cfif thecount gt 3 AND (thecount mod 4 eq
>0)></tr><tr></cfif>
> <cfset thecount=thecount+1>
> <cfelseif ListFindNoCase(Right(name, 4), ".jpg")>
> <cfif NOT ListFindNoCase(Left(name, 6),  "thumb_")>
>    <cfx_image action=""> > file="#basepath##Replace(attributes.pinfo, "/",
>"\", "all")##Name#"
> commands="
> setvar x=100
> setvar y=100
> resize <x>
> write #basepath##Replace(attributes.pinfo, "/",
>"\", "all")#thumb_#Name#">   
> <cfset reload = 1>
> </cfif>
> </cfif>
> </cfif>
></cfoutput>
><cfif reload is 1>
><!--- <cflocation
>url=""> >addtoken="No"> --->
></cfif>  
></tr>
></table>
></body>
></html>
><!--- // viewer.cfm --->
>
>
>>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to