<?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: Automatically display images in Wordpress themes</title>
	<atom:link href="http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/</link>
	<description>rob bredow</description>
	<lastBuildDate>Sun, 07 Mar 2010 15:02:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Rob</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9284</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sat, 24 Jan 2009 06:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9284</guid>
		<description>&lt;p&gt;Actually, my code is designed to display the first uploaded image for each post individually--not automatically display an image for future posts.  If you&#039;re looking to display the same image for every post, you can do that without any of the fancy code above, just by adding the appropriate img html code to your template.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Actually, my code is designed to display the first uploaded image for each post individually&#8211;not automatically display an image for future posts.  If you&#8217;re looking to display the same image for every post, you can do that without any of the fancy code above, just by adding the appropriate img html code to your template.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Ortner</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9283</link>
		<dc:creator>Mario Ortner</dc:creator>
		<pubDate>Sat, 24 Jan 2009 05:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9283</guid>
		<description>&lt;p&gt;Hi, thanks for replying. I set the size of thumbnails and medium, placed the code inside the loop, then wrote a post and uploaded a thumb photo. Is that thumbnail supposed to upload automatically in future posts, because it doesn&#039;t in mine. What am I doing wrong?
Thanks&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi, thanks for replying. I set the size of thumbnails and medium, placed the code inside the loop, then wrote a post and uploaded a thumb photo. Is that thumbnail supposed to upload automatically in future posts, because it doesn&#8217;t in mine. What am I doing wrong?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9282</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sat, 24 Jan 2009 04:38:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9282</guid>
		<description>&lt;p&gt;Hi Mario,&lt;/p&gt;

&lt;p&gt;The post loop is the part of the template that starts with something like:&lt;/p&gt;

&lt;p&gt;&lt;/code&gt;while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and ends with:&lt;/p&gt;

&lt;p&gt;&lt;/code&gt;&lt;?php endwhile; ?&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Regarding the database associated with the current post, it simply refers to the images that have been uploaded along with the current post.  This information is stored in the database--you don&#039;t have to worry about that if it doesn&#039;t make sense to you.&lt;/p&gt;

&lt;p&gt;Best of luck.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Mario,</p>
<p>The post loop is the part of the template that starts with something like:</p>
<p>while ($the_query->have_posts()) : $the_query->the_post();</p>
<p>and ends with:</p>
<p>< ?php endwhile; ?></p>
<p>Regarding the database associated with the current post, it simply refers to the images that have been uploaded along with the current post.  This information is stored in the database--you don't have to worry about that if it doesn't make sense to you.</p>
<p>Best of luck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mario Ortner</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9281</link>
		<dc:creator>Mario Ortner</dc:creator>
		<pubDate>Sat, 24 Jan 2009 01:43:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9281</guid>
		<description>&lt;p&gt;It&#039;s not working for me. Can you please clarify the following in your explanation above?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What exactly do you call &quot;Post Loop&quot;. I assume you refer to the single post template in the theme design. If you do, can you specify exactly where to insert this code?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What do you mean by &quot;database associated with the current post&quot;? Where is this database located?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thanks a lot.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>It&#8217;s not working for me. Can you please clarify the following in your explanation above?</p>
<ol>
<li>
<p>What exactly do you call &#8220;Post Loop&#8221;. I assume you refer to the single post template in the theme design. If you do, can you specify exactly where to insert this code?</p>
</li>
<li>
<p>What do you mean by &#8220;database associated with the current post&#8221;? Where is this database located?</p>
</li>
</ol>
<p>Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9163</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Thu, 15 Jan 2009 16:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9163</guid>
		<description>&lt;p&gt;This looks like a nice improvement.  I&#039;m going to give it a try too.&lt;/p&gt;

&lt;p&gt;Thanks a lot.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This looks like a nice improvement.  I&#8217;m going to give it a try too.</p>
<p>Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Taylor</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9162</link>
		<dc:creator>Steve Taylor</dc:creator>
		<pubDate>Thu, 15 Jan 2009 15:11:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9162</guid>
		<description>&lt;p&gt;Even better, WordPress does actually have built-in functions to handle this. I just discovered:&lt;/p&gt;

&lt;p&gt;http://codex.wordpress.org/Function_Reference/get_children
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src&lt;/p&gt;

&lt;p&gt;There&#039;s more functions along similar lines. My revised function, to return the specified size (&quot;full&quot;, &quot;medium&quot;, &quot;thumbnail&quot;) of the image in the specified post or page, is as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getImage( $postID, $size = &quot;thumbnail&quot; ) {
    $images = get_children( &quot;post_parent=$postID&amp;post_type=attachment&amp;post_mime_type=image&quot; );
    if ( $images ) {
        foreach( $images as $image_id =&gt; $image_infos ) {
            $the_image = wp_get_attachment_image_src( $image_id, $size );
            if ( $the_image ) {
                return $the_image[0];
                break;
            }
        }
    }
    return &quot;&quot;;
}&lt;/code&gt;&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>Even better, WordPress does actually have built-in functions to handle this. I just discovered:</p>
<p><a href="http://codex.wordpress.org/Function_Reference/get_children" rel="nofollow">http://codex.wordpress.org/Function_Reference/get_children</a><br />
<a href="http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src</a></p>
<p>There&#8217;s more functions along similar lines. My revised function, to return the specified size (&#8220;full&#8221;, &#8220;medium&#8221;, &#8220;thumbnail&#8221;) of the image in the specified post or page, is as follows:</p>
<pre><code>function getImage( $postID, $size = "thumbnail" ) {
    $images = get_children( "post_parent=$postID&amp;post_type=attachment&amp;post_mime_type=image" );
    if ( $images ) {
        foreach( $images as $image_id =&gt; $image_infos ) {
            $the_image = wp_get_attachment_image_src( $image_id, $size );
            if ( $the_image ) {
                return $the_image[0];
                break;
            }
        }
    }
    return "";
}</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Taylor</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-9045</link>
		<dc:creator>Steve Taylor</dc:creator>
		<pubDate>Fri, 02 Jan 2009 19:45:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-9045</guid>
		<description>&lt;p&gt;Thanks for a great idea. I&#039;ve been tweaking this for my purposes, and now have this function (I hope the code tag works here!):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getThumbnail( $postID, $size = &quot;thumbnail&quot; ) {
    global $wpdb;
    $image = &quot;&quot;;
    $maxWidth = get_option( $size.&#039;_size_w&#039; );
    $post_attachments = $wpdb-&gt;get_results( &quot;
        SELECT  guid
        FROM        $wpdb-&gt;posts
        WHERE       post_parent = $postID
        AND     post_type   = &#039;attachment&#039;
        ORDER BY    post_date ASC
        LIMIT       0,1
    &quot; );
    if ( $post_attachments ) {
        $sourceimage = $post_attachments[0]-&gt;guid;
        $sourceimage = str_replace( &quot;.jpg&quot;, &quot;&quot;, $sourceimage );
        $sourceimage = str_replace( &quot;.png&quot;, &quot;&quot;, $sourceimage );
        $sourceimage = str_replace( &quot;.gif&quot;, &quot;&quot;, $sourceimage );
        $sourceimage = str_replace( get_bloginfo( &quot;siteurl&quot; ), &quot;&quot;, $sourceimage );
        $root = $_SERVER[ &#039;DOCUMENT_ROOT&#039; ];
        foreach ( glob( &quot;$root$sourceimage-*$maxWidth*&quot; ) as $filename ) {
            $image = $filename;
            $image = str_replace( $root, &quot;&quot;, $image );
        }
    }
    return $image;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It defaults to getting the thumbnail, or you can ask it to get the medium size, too. It dynamically gets the WP option for the relevant max width and matches on that.&lt;/p&gt;

&lt;p&gt;This function works for my current set up - both thumbnail is set to 80 x 80 and medium is set to 150 x 150. The match allows the max width value found to be anywhere in the filename, i.e. it could end up matching the height of a thumbnail, if you have thumbnail at 80 x 150 and medium as 150 x 300, say. Not sure - please test for yourself before using, but hopefully this idea is of use to someone...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for a great idea. I&#8217;ve been tweaking this for my purposes, and now have this function (I hope the code tag works here!):</p>
<pre><code>function getThumbnail( $postID, $size = &quot;thumbnail&quot; ) {
    global $wpdb;
    $image = &quot;&quot;;
    $maxWidth = get_option( $size.'_size_w' );
    $post_attachments = $wpdb-&gt;get_results( &quot;
        SELECT  guid
        FROM        $wpdb-&gt;posts
        WHERE       post_parent = $postID
        AND     post_type   = 'attachment'
        ORDER BY    post_date ASC
        LIMIT       0,1
    &quot; );
    if ( $post_attachments ) {
        $sourceimage = $post_attachments[0]-&gt;guid;
        $sourceimage = str_replace( &quot;.jpg&quot;, &quot;&quot;, $sourceimage );
        $sourceimage = str_replace( &quot;.png&quot;, &quot;&quot;, $sourceimage );
        $sourceimage = str_replace( &quot;.gif&quot;, &quot;&quot;, $sourceimage );
        $sourceimage = str_replace( get_bloginfo( &quot;siteurl&quot; ), &quot;&quot;, $sourceimage );
        $root = $_SERVER[ 'DOCUMENT_ROOT' ];
        foreach ( glob( &quot;$root$sourceimage-*$maxWidth*&quot; ) as $filename ) {
            $image = $filename;
            $image = str_replace( $root, &quot;&quot;, $image );
        }
    }
    return $image;
}</code></pre>
<p>It defaults to getting the thumbnail, or you can ask it to get the medium size, too. It dynamically gets the WP option for the relevant max width and matches on that.</p>
<p>This function works for my current set up &#8211; both thumbnail is set to 80 x 80 and medium is set to 150 x 150. The match allows the max width value found to be anywhere in the filename, i.e. it could end up matching the height of a thumbnail, if you have thumbnail at 80 x 150 and medium as 150 x 300, say. Not sure &#8211; please test for yourself before using, but hopefully this idea is of use to someone&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-8908</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 21 Dec 2008 15:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-8908</guid>
		<description>&lt;p&gt;@Travis:  Unfortunately, I&#039;m not too familiar with that plugin.  Maybe the plugin author would want to add this feature for you?  I&#039;m considering packaging this little hack up as a plugin myself, but haven&#039;t gotten around to it yet.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Travis:  Unfortunately, I&#8217;m not too familiar with that plugin.  Maybe the plugin author would want to add this feature for you?  I&#8217;m considering packaging this little hack up as a plugin myself, but haven&#8217;t gotten around to it yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-8883</link>
		<dc:creator>Travis</dc:creator>
		<pubDate>Wed, 17 Dec 2008 21:43:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-8883</guid>
		<description>&lt;p&gt;Thanks for the article.&lt;/p&gt;

&lt;p&gt;I&#039;m trying to use this technique with the SEO Siloing plugin to draw my posts onto the page with thumbnails. I&#039;m having trouble merging the two and would REALLY appreciate any help.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for the article.</p>
<p>I&#8217;m trying to use this technique with the SEO Siloing plugin to draw my posts onto the page with thumbnails. I&#8217;m having trouble merging the two and would REALLY appreciate any help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Akip</title>
		<link>http://www.185vfx.com/2008/10/automatically-display-images-in-wordpress-themes/comment-page-1/#comment-8498</link>
		<dc:creator>Akip</dc:creator>
		<pubDate>Thu, 04 Dec 2008 09:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.185vfx.com/?p=196#comment-8498</guid>
		<description>&lt;p&gt;Perfect! Its work like a charm. Thanks for hack.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Perfect! Its work like a charm. Thanks for hack.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
