<?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>UnDeprived &#187; replaceImage</title>
	<atom:link href="http://www.un-deprived.com/tag/replaceimage/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.un-deprived.com</link>
	<description>A webdev journal of the Moninator</description>
	<lastBuildDate>Sun, 29 Aug 2010 10:00:00 +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>jQuery Journal: Easy jQuery image swap — Step by step</title>
		<link>http://www.un-deprived.com/2009/webdev/jquery-journal-easy-jquery-image-swap-step-by-step/</link>
		<comments>http://www.un-deprived.com/2009/webdev/jquery-journal-easy-jquery-image-swap-step-by-step/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 20:49:17 +0000</pubDate>
		<dc:creator>Mon</dc:creator>
				<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[imageSwap]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[replaceImage]]></category>

		<guid isPermaLink="false">http://www.un-deprived.com/?p=105</guid>
		<description><![CDATA[Image Swap Example Create thumbnails and dump them all in a “thumbs” folder with the same file names OR add something to identify the thumbnails such as: image01-th.jpg, image02-th.jpg etc… Place a container that holds the big image and give it an unique ID such as “big-image” OR give the image an unique ID - [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.un-deprived.com/wp-content/uploads/2009/07/image-swaps.html">Image Swap Example</a></p>
<ol>
<li>Create thumbnails and dump them all  in a “thumbs” folder with the same file names</li>
<li>OR add something to identify the thumbnails such as: image01-th.jpg, image02-th.jpg etc…<span id="more-105"></span></li>
<li>Place a container that holds the big image and give it an unique ID such as “big-image” OR give the image an unique ID -<strong> need a default image</strong>
<div class="wp_syntax">
<div class="code">
<pre class="html" style="font-family:monospace;">&lt;div id=&quot;big-image&quot;&gt;&lt;img src=&quot;imagename.jpg&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</pre>
</div>
</div>
<p>OR</p>
<div class="wp_syntax">
<div class="code">
<pre class="html" style="font-family:monospace;"> 	&lt;img id=&quot;big-image&quot; src=&quot;bigimage01.jpg&quot; alt=&quot;&quot; /&gt;</pre>
</div>
</div>
</li>
<li>Place all of the thumbnails within a container such as: UL, unique ID div, or add a class to each of the thumbnail
<div class="wp_syntax">
<div class="code">
<pre class="html" style="font-family:monospace;">&lt;ul id=&quot;thumbnails&quot;&gt;
	&lt;li&gt;&lt;img src=&quot;image01.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;image02.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;image03.jpg&quot; alt=&quot;&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
</div>
</div>
<p>OR</p>
<div class="wp_syntax">
<div class="code">
<pre class="html" style="font-family:monospace;">&lt;div id=&quot;thumbnails&quot;&gt;
        &lt;img src=&quot;image01.jpg&quot; alt=&quot;&quot; /&gt;
        &lt;img src=&quot;image02.jpg&quot; alt=&quot;&quot; /&gt;
        &lt;img src=&quot;image03.jpg&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</pre>
</div>
</div>
<p>OR</p>
<div class="wp_syntax">
<div class="code">
<pre class="html" style="font-family:monospace;">  	&lt;img class=&quot;thumbnails&quot; src=&quot;image01.jpg&quot; alt=&quot;&quot; /&gt;
    &lt;img class=&quot;thumbnails&quot; src=&quot;image02.jpg&quot; alt=&quot;&quot; /&gt;
    &lt;img class=&quot;thumbnails&quot; src=&quot;image03.jpg&quot; alt=&quot;&quot; /&gt;</pre>
</div>
</div>
<p><em>Note: </em>The last method is more flexible, it doesn’t have to be inside a container meaning the thumbnail can be placed anywhere. Just as long as the bigger image is shown at the exact same place.</li>
<li>Tell jQuery to find all the thumbnails, and every time the user hovers over each of the thumbnail – replace the “big-image” with the corresponding thumbnail path or file name</li>
</ol>
<p>To replace the path:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#thumbnails img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> src <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'thumbs'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// take out /thumbs/ before the file name</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#big-image'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>src<span style="color: #339933;">:</span> src<span style="color: #339933;">,</span> title<span style="color: #339933;">:</span> src<span style="color: #339933;">,</span> alt<span style="color: #339933;">:</span> src<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>To remove the “_th” identifiers:</p>
<div class="wp_syntax">
<div class="code">
<pre class="javascript" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#thumbnails img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #003366; font-weight: bold;">var</span> src <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'_th'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// take out '-th'</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#big-image'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>src<span style="color: #339933;">:</span> src<span style="color: #339933;">,</span> title<span style="color: #339933;">:</span> src<span style="color: #339933;">,</span> alt<span style="color: #339933;">:</span> src<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre>
</div>
</div>
<p>To find all the “thumbnails” classes: <em>Simply replace $(‘#thumbnails img’) </em>with<em> $(‘.thumbnails’)</em><!-- PHP 5.x --></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.un-deprived.com/2009/webdev/jquery-journal-easy-jquery-image-swap-step-by-step/feed/</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>
