<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dingobytes &#187; image</title>
	<atom:link href="http://www.dingobytes.com/tag/image/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dingobytes.com</link>
	<description>what your nephew can't make you</description>
	<lastBuildDate>Fri, 11 Jun 2010 03:26:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Coldfusion Image Rotator</title>
		<link>http://www.dingobytes.com/coldfusion/coldfusion-image-rotator</link>
		<comments>http://www.dingobytes.com/coldfusion/coldfusion-image-rotator#comments</comments>
		<pubDate>Mon, 03 Mar 2008 19:15:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[rotator]]></category>
		<category><![CDATA[turorial]]></category>

		<guid isPermaLink="false">http://www.dingobytes.com/2008/03/03/coldfusion-image-rotator/</guid>
		<description><![CDATA[I was tasked a few months ago to rotate an image on a site randomly. Ordinarily this would not be an issue but the image was a css background image and I really didn&#8217;t have the ambition to rewrite the css and page html to do this. Thankfully my laziness paid off, because I found [...]]]></description>
			<content:encoded><![CDATA[<p>I was tasked a few months ago to rotate an image on a site randomly. Ordinarily this would not be an issue but the image was a css background image and I really didn&#8217;t have the ambition to rewrite the css and page html to do this. Thankfully my laziness paid off, because I found a solution while looking through some php code for wordpress.</p>
<p><span id="more-7"></span>I ran into this template that I liked, but wanted to change the header image. I changed it, uploaded it and refreshed the page, but NOTHING changed. I spent a good 5 minutes on this before checking the css to see what was going on. Instead of finding a path to an image in the css for the background, I found a path to a file named rotate.php. The script was written by Matt Mullenweg (<a href="http://photomatt.net/scripts/randomimage">http://photomatt.net/scripts/randomimage</a>) and seemed simple enough to me. What I liked about this script is that it didn&#8217;t require managing a bunch of images. If you want an image you simply stick it in a predefined directory and point to that directory.</p>
<p>I decided to rewrite this in coldfusion and within a few minutes I had a working. It is rather simple. Define your folder, define your extensions and define the url path to the folder and you are done. You will find the code below.</p>
<p><code><font size="2" color="#800000"><br />
&lt;cftry&gt;</font><br />
<font size="2" color="#808080">&lt;!---<br />created by Andrew Alba &gt;&gt; <a href="http://www.albawebstudio.com/">http://www.albawebstudio.com</a><br />This will grab images from specified folder and randomly display them<br />You will only need to modify the three variables below<br />---&gt;</font><br />
<font size="2" color="#808080"><br />
&lt;!--- Insert the absolute path (with trailing slash) to the images.<br />"/home/mysite/public_html/images/" or "/www/mysite/web/images/random/"<br />If the images are in the same directory as<br />this script you can leave it as shown file<br />---&gt;<br />
</font><br />
<font size="2" color="#800000"><br />
&lt;cfset<font size="2"> folder = </font><font size="2" color="#0000ff">"#GetDirectoryFromPath(GetBaseTemplatePath())#"</font><font size="2" color="#800000">&gt;</font><br />
</font><br />
<font size="2" color="#808080">&lt;!--- List of allowed extensions (separate with space) ---&gt;</font><br /><font size="2" color="#800000">&lt;cfset</font><font size="2"> ext = </font><font size="2" color="#0000ff">"jpg jpeg png gif"</font><font size="2" color="#800000">&gt;</font><br />
<font size="2" color="#808080"><br />
&lt;!--- Insert the URL to the folder that contains the images ---&gt;<br /><font size="2" color="#800000">&lt;cfset</font><font size="2"> url_image_path = </font><font size="2" color="#0000ff">"http://www.homeshq.com/gfx/promotion/"</font><font size="2" color="#800000">&gt;</font><br />
</font><br />
<font size="2" color="#808080"><br />
&lt;!--- do not edit below this point ---&gt;<br />&lt;!--- lets get the contents of the folder ---&gt;<br /><font size="2" color="#800000">&lt;cfdirectory</font><font size="2"> </font><font size="2" color="#800000">directory=</font><font size="2" color="#0000ff">"#folder#"</font><font size="2"> </font><font size="2" color="#800000">action=</font><font size="2" color="#0000ff">"list"</font><font size="2"> </font><font size="2" color="#800000">name=</font><font size="2" color="#0000ff">"filelisting"</font><font size="2" color="#800000">&gt;</font><br />
</font><font size="2" color="#808080"><br />
&lt;!--- pull just file names out of the list ---&gt;<br /><font size="2" color="#800000">&lt;cfset</font><font size="2"> fileList = </font><font size="2" color="#0000ff">""</font><font size="2" color="#800000">&gt;<br />
</font><font size="2" color="#800000">&lt;cfoutput</font><font size="2"> </font><font size="2" color="#800000">query=</font><font size="2" color="#0000ff">"filelisting"</font><font size="2" color="#800000">&gt;<br />
</font><font size="2" color="#800000">&lt;cfif</font><font size="2"> filelisting.type </font><font size="2" color="#0000ff">is</font><font size="2"> </font><font size="2" color="#0000ff">"file"</font><font size="2" color="#800000">&gt;<br />
</font><font size="2" color="#800000">&lt;cfset</font><font size="2"> fileList = </font><font size="2" color="#000066">listappend</font><font size="2">(fileList,filelisting.name)</font><font size="2" color="#800000">&gt;<br />
</font><font size="2" color="#800000">&lt;/cfif&gt;<br />
&lt;/cfoutput&gt;</font><br />
</font><br />
<font size="2" color="#808080"><br />
&lt;!--- now we can create a new list of files ---&gt;<br /><font size="2" color="#800000">&lt;cfset</font><font size="2"> new_fileList = </font><font size="2" color="#0000ff">""</font><font size="2" color="#800000">&gt;<br />
</font><font size="2" color="#800000">&lt;cfloop</font><font size="2"> </font><font size="2" color="#800000">list=</font><font size="2" color="#0000ff">"#fileList#"</font><font size="2"> </font><font size="2" color="#800000">index=</font><font size="2" color="#0000ff">"i"</font><font size="2"> </font><font size="2" color="#800000">delimiters=</font><font size="2" color="#0000ff">","</font><font size="2" color="#800000">&gt;</font><br /><font size="2" color="#808080">  &lt;!--- lets use our list of extensions to <br />weed out the files types we don't want ---&gt;<br /></font><font size="2" color="#808080">  &lt;!--- now we grab just the extension ---&gt;<br />
</font><br /><font size="2" color="#800000">  &lt;cfset</font><font size="2"> file_ext = </font><font size="2" color="#000066">listlast</font><font size="2">(i,</font><font size="2" color="#0000ff">"."</font><font size="2">)</font><font size="2" color="#800000">&gt;</font><br /><font size="2" color="#808080">  &lt;!--- if it finds file_ext is acceptable as per<br />
ext then it adds it to the array ---&gt;</font><br /><font size="2" color="#800000">&lt;cfif</font><font size="2"> </font><font size="2" color="#000066">listfindnocase</font><font size="2">(ext,file_ext,</font><font size="2" color="#0000ff">" "</font><font size="2">)</font><font size="2" color="#800000">&gt;<br />
    </font><font size="2" color="#800000">&lt;cfset</font><font size="2"> new_fileList = </font><font size="2" color="#000066">listappend</font><font size="2">(new_fileList,i)</font><font size="2" color="#800000">&gt;<br />
  </font><font size="2" color="#800000">&lt;/cfif&gt;<br />
</font><font size="2" color="#800000">&lt;/cfloop&gt;</font><br />
</font><font size="2" color="#808080"><br />
&lt;!--- now to choose random number from the list ---&gt;<br /><font size="2" color="#800000">&lt;cfset</font><font size="2"> image_file =<br />
</font><font size="2" color="#000066">listgetat</font><font size="2">(new_fileList,</font><font size="2" color="#000066">randrange</font><font size="2">(</font><font size="2" color="#ff0a0a">1</font><font size="2">,</font><font size="2" color="#000066">listlen</font><font size="2">(new_fileList),</font><font size="2" color="#0000ff">"SHA1PRNG"</font><font size="2">),</font><font size="2" color="#0000ff">","</font><font size="2">)</font><font size="2" color="#800000">&gt;</font><br />
</font><font size="2" color="#800000"><br />
&lt;cflocation<font size="2"> </font><br /><font size="2" color="#800000">url=</font><font size="2" color="#0000ff">"#url_image_path##image_file#?rand=#randrange(1,999999999,"</font><font size="2" color="#800000">SHA1PRNG</font><font size="2" color="#0000ff">")#"</font><br /><font size="2" color="#800000">addtoken=</font><font size="2" color="#0000ff">"no"</font><font size="2" color="#800000">&gt;</font><br />
</font><font size="2" color="#800000"><br />
&lt;cfcatch<font size="2"> </font><font size="2" color="#800000">type=</font><font size="2" color="#0000ff">"any"</font><font size="2" color="#800000">&gt;&lt;/cfcatch&gt;<br />
&lt;/cftry&gt;</font><br />
</font></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dingobytes.com/coldfusion/coldfusion-image-rotator/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
