<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Find the first image in a WordPress post</title>
	<atom:link href="http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/</link>
	<description>WordPress made easy</description>
	<lastBuildDate>Tue, 09 Mar 2010 22:55:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Sue</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1723</link>
		<dc:creator>Sue</dc:creator>
		<pubDate>Tue, 27 Oct 2009 10:42:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1723</guid>
		<description>Yes, easily - just put an if/else loop into the code.</description>
		<content:encoded><![CDATA[<p>Yes, easily - just put an if/else loop into the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ceys</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1686</link>
		<dc:creator>Ceys</dc:creator>
		<pubDate>Fri, 23 Oct 2009 14:24:12 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1686</guid>
		<description>Hiya, this looks really excellent, but I had a question (I&#039;m learning php slooowly):

Is there a way where if there is no image present you can automatically substitute with a default image?

I&#039;d like to use it on my photography blog once I redesign it and start posting again, but I very occasionally post without photos and it&#039;d be good to have something there to keep it looking consistent!

Thank you :)
Cerys</description>
		<content:encoded><![CDATA[<p>Hiya, this looks really excellent, but I had a question (I'm learning php slooowly):</p>
<p>Is there a way where if there is no image present you can automatically substitute with a default image?</p>
<p>I'd like to use it on my photography blog once I redesign it and start posting again, but I very occasionally post without photos and it'd be good to have something there to keep it looking consistent!</p>
<p>Thank you <img src='http://blogmum.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Cerys</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrea</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1570</link>
		<dc:creator>andrea</dc:creator>
		<pubDate>Tue, 13 Oct 2009 14:13:30 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1570</guid>
		<description>Thanks for fast reply Sue, problem is that I don&#039;t know how to write in PHP so I cannot make the code by myself. If you or someone here know where I can find a similar code that works will be great...</description>
		<content:encoded><![CDATA[<p>Thanks for fast reply Sue, problem is that I don't know how to write in PHP so I cannot make the code by myself. If you or someone here know where I can find a similar code that works will be great...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sue</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1569</link>
		<dc:creator>Sue</dc:creator>
		<pubDate>Tue, 13 Oct 2009 14:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1569</guid>
		<description>If you use the getimagesize() PHP function, Andrea, you should be able to do whatever you like.</description>
		<content:encoded><![CDATA[<p>If you use the getimagesize() PHP function, Andrea, you should be able to do whatever you like.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: andrea</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1568</link>
		<dc:creator>andrea</dc:creator>
		<pubDate>Tue, 13 Oct 2009 14:04:45 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1568</guid>
		<description>Hello, I need exactly what Arch1k wrote about, a code that embed the original width and height of the image. But the code posted don&#039;t work. When I add the code in the functions.php and save the page returns a blank page and the entire blog stops working. Any help to make the code of Arch1k work correctly? Thanks</description>
		<content:encoded><![CDATA[<p>Hello, I need exactly what Arch1k wrote about, a code that embed the original width and height of the image. But the code posted don't work. When I add the code in the functions.php and save the page returns a blank page and the entire blog stops working. Any help to make the code of Arch1k work correctly? Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jzatt</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1339</link>
		<dc:creator>Jzatt</dc:creator>
		<pubDate>Sat, 19 Sep 2009 15:03:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1339</guid>
		<description>Awesome! This was just what I was looking for. Have been searching for a way to extract the first link for a while, this works just the way I want it! Thanks alot, really saved my day!</description>
		<content:encoded><![CDATA[<p>Awesome! This was just what I was looking for. Have been searching for a way to extract the first link for a while, this works just the way I want it! Thanks alot, really saved my day!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sue</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1134</link>
		<dc:creator>Sue</dc:creator>
		<pubDate>Sat, 05 Sep 2009 18:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1134</guid>
		<description>Thanks Mark! 
Memo to self: fix comments so people can post code...</description>
		<content:encoded><![CDATA[<p>Thanks Mark!<br />
Memo to self: fix comments so people can post code...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-1132</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sat, 05 Sep 2009 17:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-1132</guid>
		<description>[Edit by Sue: code below not tested by or supported by me]
I added a &quot;no image found&quot; function: 

	$content = get_the_content();
	$pic_string = bm_extract_string(&#039;src=&quot;&#039;,&#039;&quot; &#039;,$content);
	if ( $pic_string == NULL ) {
		echo &#039;&#039;;
	} else {
		echo &#039;&#039;;
	}

Edit: I can&#039;t get the code to show up correctly.
It searches for the first image, if it is not there it inserts a path to a generic image</description>
		<content:encoded><![CDATA[<p>[Edit by Sue: code below not tested by or supported by me]<br />
I added a "no image found" function: </p>
<p>	$content = get_the_content();<br />
	$pic_string = bm_extract_string('src="','" ',$content);<br />
	if ( $pic_string == NULL ) {<br />
		echo '';<br />
	} else {<br />
		echo '';<br />
	}</p>
<p>Edit: I can't get the code to show up correctly.<br />
It searches for the first image, if it is not there it inserts a path to a generic image</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ←intrtxt monoblogue→</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-848</link>
		<dc:creator>←intrtxt monoblogue→</dc:creator>
		<pubDate>Sun, 09 Aug 2009 16:48:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-848</guid>
		<description>[...] webpage, so I went on digging deeper. Thankfully I found the Blog Mum blog which gave me a profound yet creative solution. However, I had to have the height and width of my images(divs with background actually) embedded [...]</description>
		<content:encoded><![CDATA[<p>[...] webpage, so I went on digging deeper. Thankfully I found the Blog Mum blog which gave me a profound yet creative solution. However, I had to have the height and width of my images(divs with background actually) embedded [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arch1k</title>
		<link>http://blogmum.com/2009/06/find-the-first-image-in-a-wordpress-post/#comment-842</link>
		<dc:creator>Arch1k</dc:creator>
		<pubDate>Sun, 09 Aug 2009 03:18:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogmum.com/?p=722#comment-842</guid>
		<description>[Edit by Sue: code below not tested by or supported by me]

Sorry for all this mess.  Hope this one turns out right:
Functions.php hase this:
// Retrieve the src pf first image in a post
function bm_extract_string($start, $end, $original) {
$original = stristr($original, $start);
$trimmed = stristr($original, $end);
return substr($original, strlen($start), -strlen($trimmed));
}
function getFirstImage() {
$content = get_the_content(); $pic_string = bm_extract_string(’src=”‘,’” ‘,$content);
$imagesize = getimagesize($pic_string);
list($width, $height, $type, $attr) = getimagesize($pic_string);
echo &#039;&lt; a href=&quot;&#039;.$link.&#039;&quot; style=&quot;background:url(&#039;.$pic_string.&#039;); display:block; width:&#039;.$width.&#039;px; height:&#039;.$height.&#039;px;&quot;&gt;&lt;/a&gt; ‘;
}

and inside your index.php simply put this:
&lt;?php getFirstImage(); ?&gt;</description>
		<content:encoded><![CDATA[<p>[Edit by Sue: code below not tested by or supported by me]</p>
<p>Sorry for all this mess.  Hope this one turns out right:<br />
Functions.php hase this:<br />
// Retrieve the src pf first image in a post<br />
function bm_extract_string($start, $end, $original) {<br />
$original = stristr($original, $start);<br />
$trimmed = stristr($original, $end);<br />
return substr($original, strlen($start), -strlen($trimmed));<br />
}<br />
function getFirstImage() {<br />
$content = get_the_content(); $pic_string = bm_extract_string(’src=”‘,’” ‘,$content);<br />
$imagesize = getimagesize($pic_string);<br />
list($width, $height, $type, $attr) = getimagesize($pic_string);<br />
echo '&lt; a href="'.$link.'" style="background:url('.$pic_string.'); display:block; width:'.$width.'px; height:'.$height.'px;"&gt;&lt;/a&gt; ‘;<br />
}</p>
<p>and inside your index.php simply put this:<br />
&lt;?php getFirstImage(); ?&gt;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
