<?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>Fresh Lime Soda &#187; Short Codes</title>
	<atom:link href="http://www.freshlimesoda.us/category/wordpress-themes/short-codes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.freshlimesoda.us</link>
	<description>The Supreme Thirst Quencher!</description>
	<lastBuildDate>Wed, 21 Jul 2010 12:00:54 +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>How to Get Image for a post</title>
		<link>http://www.freshlimesoda.us/how-to-get-image-for-a-post/</link>
		<comments>http://www.freshlimesoda.us/how-to-get-image-for-a-post/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 10:00:48 +0000</pubDate>
		<dc:creator>Fresh Lime Soda</dc:creator>
				<category><![CDATA[Short Codes]]></category>
		<category><![CDATA[Wordpress Themes]]></category>

		<guid isPermaLink="false">http://www.freshlimesoda.us/?p=56</guid>
		<description><![CDATA[A picture is worth a thousand words and so a good wordpress theme has to have a lot of images. I usually use the function below which I can call from my theme pages to retrieve an image for an post.]]></description>
			<content:encoded><![CDATA[<h2>A picture is worth a thousand words</h2>
<p>A picture is worth a thousand words and so a good wordpress theme has to have a lot of images. I usually use the function below which I can call from my theme pages to retrieve an image for an post.</p>
<pre name="code" class="php">
function get_post_image( $iImageNumber = 0, $iSize = "thumbnail", $bPrint = false )
{
	global $post;
	global $wpdb;
	$attachment_id = $wpdb-&gt;get_var("SELECT ID FROM $wpdb-&gt;posts WHERE post_parent = '$post-&gt;ID' AND
          post_status = 'inherit' AND ( post_mime_type = 'image/gif' OR post_mime_type = 'image/jpeg'
          OR post_mime_type = 'image/png' ) AND post_type='attachment' ORDER BY post_date ASC LIMIT 1");

	$pics = wp_get_attachment_url($attachment_id, $size, false);

	// If not image found as an attachment,
	// then look inside the content for embeded images
	if($pics == "")
	{
		$szPostContent = $post-&gt;post_content;
		$szSearchPattern = '//';
		preg_match( $szSearchPattern, $szPostContent, $images );
		$pics = $images[1];
	}

	// If still not found then use a default image
	if($pics == "") {
		$loc = get_bloginfo('template_directory');
		$pics = $loc . "/images/post-default-large.jpg";
	}
	if ( $bPrint == true &amp;&amp; !empty($pics) ) echo "<img src="$pics" alt="" />"; else return $pics;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.freshlimesoda.us/how-to-get-image-for-a-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
