Hi Blair, I've tested on: FF 2 IE 6+7 and it all looks good. If the browser supports 302 temporary redirects (which is what cflocation is now doing under the hood) then it should all be sweet. cheers David
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Blair McKenzie Sent: Friday, 18 May 2007 11:52 AM To: [email protected] Subject: [farcry-dev] Re: TIP: Displaying images in dmHTML pages Will this work for all browsers? I've heard that some older ones don't handle redirects very well. Blair On 5/18/07, David Whiterod < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: Hi, One of the things that I haven't liked when users create dmHTML objects is the hard-coding of image URLs within the body. Others may have developed workarounds, but I was looking at Ben Nadel's blog the other day and he was taking about a simple method to log file downloads in CF [1]. I thought the method he described would be a good way to 'solve' the hard-coding issue. To this end, I've have created a proxy.cfm template (this can go in your webroot folder) and an example dmImage inserthtml snippet [2]. (These files have been created for, and testing, on FarCry 4 but they wouldn't need too much change to work with a FarCry 3 setup). Firstly the inserthtml. It's pretty basic as it just replaces the img's src with a call to proxy.cfm?objectid=<the image's UUID> instead of the image's URL path. Yyou can also supply the (optional) imagesize param. ie proxy.cfm?objectid=<the image's UUID>&imagesize=<thumb, optimised or original>) ie: <!--- @@displayname: Link (via proxy) ---> <cfoutput><img alt='#stObj.alt#' title='#stObj.alt#' src="#application.url.webroot#/proxy.cfm?objectid=#stObj.objectid#" / ></cfoutput> Secondly, the proxy.cfm templateiso only marginally more complex. It just takes the objected and (optional) imagesize (via the URL), gets the FarCry object and cflocations to the current image URL. This allows users to update the physical image (and location and filename) associated with a FarCry dmImage object and the links within the dmHTML bodys do not need to be changed. The good thing about using the cflocation method is that the image will also shows up in the rich text editor when users are editing the dmHTML objects! (Although this does need to do a database lookup it you turn on FarCry 4's objectbroker for the image type this should cut down the amount of db traffic.) The code for proxy.cfm looks like: <cfsetting enablecfoutputonly="true" /> <cfparam name="URL.objectid" type="string" default="" /> <cfparam name="URL.ImageSize" type="string" default="optimised" /> <cfif len(trim(URL.objectid))> <cfset oImage = createObject("component", "#application.types.dmImage.typePath#")> <cfset imagePath = oImage.getURLImagePath(URL.objectid, URL.ImageSize) /> <cfif len(trim(imagePath))> <cflocation url="#imagePath#" addtoken="false" /> <cfelse> <cfoutput>image not found</cfoutput> <!--- trace or report this error ---> </cfif> <cfelse> <cfoutput>Must supply object id</cfoutput> <!--- trace or report this error ---> </cfif> In summary, this looks like a good solution to the problem. Questions/comments/suggestions? (I've tested this on Windows/IIS but I don't see issues with other setups) Cheers David [1] http://www.bennadel.com/index.cfm?dax=blog:706.view [2] http://docs.farcrycms.org:8080/confluence/display/FCDEV30/Insert+HTML+Te mplates --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "farcry-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/farcry-dev?hl=en -~----------~----~----~----~------~----~------~--~---
