Search

Archives

Categories

Latest via Twitter

No public Twitter messages.
Follow me: @JessieCanon

How to use JQuery lightbox with cfimage

April 22nd, 2011

Recently I needed to pull images dynamically from a network drive, and be able to use JQuery lightbox with them. So I came up with a small function to assist me.

I wanted to use cfimage to accomplish this, but all I really wanted was the temporary filename ColdFusion generates to display the file to the screen. That way I could use it with regular HTML tags.

First, I performed a cfimage “Read” on the network drive location where the image was stored.

1
<cfimage action="read" source="#APPLICATION.uploadPath#\#uploaded_photo#" name="newPhotoName" />

APPLICATION.uploadPath” is a variable I use to store the actual file path where the images are stored.
uploaded_photo” is the database field that contains the filename.

newPhotoName” will now be assigned to something we really can’t make sense of. It will look something like this, “coldfusion.image.Image@29ff90bf”. So what do we do with it?

Lets pass this string into our function.

1
<cfset newPhotoName = getCustomImg(newPhotoName) />
1
2
3
4
5
6
7
8
9
10
<cffunction name="getCustomImg" access="public" returntype="string" output="false">
    <cfargument name="image" type="string" required="true" />
    <cfset var cfFileURL= "" />
    <cfsavecontent variable="cfFileURL">
        <cfimage action="writetobrowser" source="#ARGUMENTS.image#" />
    </cfsavecontent>
    <cfset cfFileURL = replace(cfFileURL, '<img src="', '') />
    <cfset cfFileURL = replace(cfFileURL, '" alt="" />', '') />
    <cfreturn trim(cfFileURL) />
</cffunction>

OK, so what does this function do?

What I’m really after here is the full URL path to the temporary ColdFusion image. So I do a “cfsavecontent” to capture the output as variable I can parse later.

Inside of my “cfsavecontent“, I use the “cfimage” tag with the action “writetobrowser“. This will actually give me the HTML markup for the image to display to the browser. You’ll wind up with something like this:

1
<img src="http://www.your-url.com/CFFileServlet/_cf_image/_cfimg-4341467501479857784.PNG" alt="" />

Next, our function is going to strip out all of the HTML we don’t want.

1
2
<cfset cfFileURL = replace(cfFileURL, '<img src="', '') />
<cfset cfFileURL = replace(cfFileURL, '" alt="" />', '') />

Now we have a fully usable image path we can use however we like. “http://www.your-url.com/CFFileServlet/_cf_image/_cfimg-4341467501479857784.PNG”

Finally, just use your variable in your HTML markup.

1
<a href="#newPhotoName#" rel="lightbox"><img src="#newPhotoName#"/></a>

Hope this helps!

Share:
  • Print
  • email
  • RSS
  • Facebook
  • Twitter
  • LinkedIn
  • Google Bookmarks
  • Google Buzz
  • Digg
  • del.icio.us
  • StumbleUpon

Fixing WordPress 3.1 404 Errors

March 29th, 2011

I’m still loving all of the new features in WordPress 3.1, even though I have run into a few snags. After updating one of my client’s sites, I noticed that every single page and post was giving a 404 error. I did all of the usual things, checking my .htaccess file, made sure mod_rewrite was working etc… After seeing it wasn’t any of those I decided to disable my plugins to see if that was causing the problem, and YES!

If you are experiencing 404′s in WordPress 3.1 follow these steps:

  1. Disable all of your plugins and see if that is the root of the problem.
  2. Turn your plugins back on, 1 by 1 until you find the offending plugin.
  3. Empty your WordPress cache.
  4. Go to “Settings”, “Permalinks” and press save. This will refresh your permalink structure.

For me, the offending plugin was “Top Level Categories”. Glad that’s over with!

Share:
  • Print
  • email
  • RSS
  • Facebook
  • Twitter
  • LinkedIn
  • Google Bookmarks
  • Google Buzz
  • Digg
  • del.icio.us
  • StumbleUpon

WordPress 3.1 Admin Bar Missing

March 15th, 2011

I use WordPress for many of my clients, including myself, so I’ve been ecstatic over the changes since 3.0. However, in 3.1 I noticed that some of my WordPress sites displayed the new admin toolbar on their pages, while others did not. If you are logged in and just see a blank space with no admin bar, you are probably missing the wp_footer() tag in your footer.php file. Once I added that in, poof, problem solved.

1
2
3
    <?php wp_footer(); ?>
</body>
</html>
Share:
  • Print
  • email
  • RSS
  • Facebook
  • Twitter
  • LinkedIn
  • Google Bookmarks
  • Google Buzz
  • Digg
  • del.icio.us
  • StumbleUpon

Welcome

March 1st, 2011

I’ve tried to keep a blog at various times in my life, but they never seemed to work out. I’ve always managed to delete them, and start over. Well hopefully that won’t happen again… I’ve been a web developer for the past 5 years, mostly using ColdFusion. I plan to use this space to write about my ever expanding knowledge on the subject, receive help from the web development community and to share my trials and misfortunes along the way.

My biggest inspirations are: My wife Somer; her fanatical love for writing has made me both very proud and envious. Raymond Camden & Ben Nadel; their ColdFusion blogs have saved me countless times, and have always been the bar for which I am constantly trying to reach.

Share:
  • Print
  • email
  • RSS
  • Facebook
  • Twitter
  • LinkedIn
  • Google Bookmarks
  • Google Buzz
  • Digg
  • del.icio.us
  • StumbleUpon