<?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>Keep Walking &#187; Thumbnail</title>
	<atom:link href="http://www.aowaa.com/tag/thumbnail/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.aowaa.com</link>
	<description>Free Wordpress Theme, Make Money Online And Cool Gadgets</description>
	<lastBuildDate>Fri, 10 Jun 2011 14:23:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Get Thumbnail Automatically from WordPress Posts</title>
		<link>http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/</link>
		<comments>http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 09:07:39 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[Thumbnail]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.aowaa.com/?p=186</guid>
		<description><![CDATA[If you are the Hybrid WordPress theme user, you may found that the Hybrid theme can get the thumbnail form your blog without any setting. Not only the Hybrid but also all the child theme of Hybrid can do this. Sometimes, your reader can easily know the content from the post title with the thumbnail. [...]]]></description>
			<content:encoded><![CDATA[<p>If you are the <a href="http://www.aowaa.com/free-wordpress-theme-hybrid/" target="_self">Hybrid WordPress theme</a> user, you may found that the Hybrid theme can get the <a href="http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/" target="_self">thumbnail</a> form your blog without any setting. Not only the Hybrid but also all the child theme of Hybrid can do this. Sometimes, your reader can easily know the content from the post title with the thumbnail. You can see the demo form <a href="http://www.caxblog.com/category/about-wordpress/" target="_self">here</a>.</p>
<p>It’s not too difficult to you if you know a little PHP coding. There’s en easy way to show the thumbnail in your blog. And you must add some code to the <code>functions.php</code> file in your <a href="http://www.aowaa.com/tag/theme/" target="_self">wordpress theme</a> directory.</p>
<p><img class="alignnone size-full wp-image-189" title="blogging-thumbnail" src="http://www.aowaa.com/wp-content/uploads/2009/04/blogging-thumbnail.jpg" alt="blogging-thumbnail" width="448" height="275" /></p>
<p><span id="more-186"></span>Open the <code>functions.php</code> file with some code editor and plaster this code between the <code>&lt;? php</code>and <code>?&gt;</code>in your <code>functions.php</code> file, and then save it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> catch_that_image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">,</span> <span style="color: #000088;">$posts</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$first_img</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
 <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #990000;">ob_end_clean</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&amp;lt;img.+src=[\'&quot;]([^\'&quot;]+)[\'&quot;].*&amp;gt;/i'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>post_content<span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000088;">$first_img</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$matches</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$first_img</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//Defines a default image</span>
 <span style="color: #000088;">$first_img</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;your default Thumbnail URL&quot;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$first_img</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This code means it can find the first photo of your posts and got it as the <a href="http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/" target="_self">thumbnail</a>, if there’s no photo in your post it will show what you set in <code>$first_img</code>. When you finish this coding, add this code in what you want the thumbnail show.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;&amp;lt;?php printf( __( 'Permalink to %s' ), the_title_attribute('echo=0') ) ?&amp;gt;&quot;</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;bookmark&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;&amp;lt;?php the_permalink() ?&amp;gt;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;thumbnail&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;&amp;lt;?php echo catch_that_image() ?&amp;gt;&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>In the end add this css code in your style.css file.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.thumbnail</span> 	<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span>height<span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span>margin<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">12px</span> <span style="color: #933;">6px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>padding<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>background<span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>border<span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddd</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.sticky</span> <span style="color: #6666ff;">.thumbnail</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span>border<span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>And now it&#8217;s done, you can see the first photo of your post in the left side of your blog.</p>
<hr />
<p><small>© Alex for <a href="http://www.aowaa.com">Keep Walking</a>, 2009. |
<a href="http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/">Permalink</a> |
<a href="http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/#comments">6 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/&title=How to Get Thumbnail Automatically from WordPress Posts">del.icio.us</a>
<br/>
Post tags: <a href="http://www.aowaa.com/tag/hacks/" rel="tag">Hacks</a>, <a href="http://www.aowaa.com/tag/theme/" rel="tag">Theme</a>, <a href="http://www.aowaa.com/tag/thumbnail/" rel="tag">Thumbnail</a>, <a href="http://www.aowaa.com/tag/tutorial/" rel="tag">Tutorial</a>, <a href="http://www.aowaa.com/tag/wordpress/" rel="tag">Wordpress</a><br/>
</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.aowaa.com/how-to-get-thumbnail-automatically-from-wordpress-posts/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

