<?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>WP Engineer &#187; post_thumbnail</title>
	<atom:link href="http://wpengineer.com/tag/post_thumbnail/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use WordPress Post Thumbnail as Background image</title>
		<link>http://wpengineer.com/2123/use-wordpress-post-thumbnail-as-background-image/</link>
		<comments>http://wpengineer.com/2123/use-wordpress-post-thumbnail-as-background-image/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 11:05:34 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WordPress Themes]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[post_thumbnail]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=2123</guid>
		<description><![CDATA[Now and then you need in a post or page a catchy image. For editors the thumbnail function is quite comfortable to assign an image to a post or a page. Therefore it is worthwhile to use this picture as a background image for the post. However, it is much better if the image is [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-2010-12.jpg" alt="" title="WordPress-Christmas-2010-12" width="400" height="267" class="aligncenter size-full wp-image-2129" /><img src="http://wpengineer.com/wp-content/uploads/post-thumbnail.png" alt="" title="post-thumbnail" width="303" height="171" class="alignright size-full wp-image-2124" /><br />
Now and then you need in a post or page a catchy image. For editors the thumbnail function is quite comfortable to assign an image to a post or a page. Therefore it is worthwhile to use this picture as a background image for the post. However, it is much better if the image is defined via CSS in the background and it doesn't appear in the markup. Therefore, a small function that defines a default image and if there is a defined post thumbnail, then this will be used.<br />
<span id="more-2123"></span><br />
The function is only a small solution, therefore, it must be adapted and expanded to your liking. Have fun.</p>
<pre>
/**
 * return post thumbnail inside style in head
 */
if ( !function_exists(&#039;fb_background_image&#039;) ) {

	function fb_background_image() {
		// only frontend
		if ( is_feed() || is_trackback() ) {
			return;
		}

		// default image, when no set an post thumbnail
		if ( !has_post_thumbnail($GLOBALS&#091;&#039;post&#039;&#093;-&gt;ID) ) {
			$style = &#039;&lt;style type=&quot;text/css&quot;&gt;.banner {background-image:url(\&#039;&#039; . get_bloginfo(&#039;stylesheet_directory&#039;) . &#039;/images/banner.jpg\&#039;);} &lt;/style&gt;&#039; . &quot;\n\n&quot;;
		} else {
			// get post thumbnail
			$image = wp_get_attachment_image_src(
				get_post_thumbnail_id($GLOBALS&#091;&#039;post&#039;&#093;-&gt;ID),
				&#039;banner&#039; // size for image; defined via add_image_siz
			);

			$style = sprintf(
				&#039;&lt;style type=&quot;text/css&quot;&gt;.banner {background-image:url(\&#039;%s\&#039;);}&lt;/style&gt;&#039;,
				esc_attr($image&#091;0&#093;),
				&quot;\n\n&quot;
			);
		}
		if ($style)
			echo $style;
	}

	// add functions
	add_action( &#039;wp_head&#039;, &#039;fb_background_image&#039; );
	add_theme_support( &#039;post-thumbnails&#039; );
	add_image_size( &#039;banner&#039;, 980, 350, true );

}
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/2123/use-wordpress-post-thumbnail-as-background-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress 2.9 add_theme_support and has_post_image</title>
		<link>http://wpengineer.com/1779/wordpress-2-9-add_theme_support-and-has_post_image/</link>
		<comments>http://wpengineer.com/1779/wordpress-2-9-add_theme_support-and-has_post_image/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 21:16:55 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress News]]></category>
		<category><![CDATA[post_thumbnail]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[wp2.9]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1779</guid>
		<description><![CDATA[The new the_post_image functionality in WordPress version 2.9 has been enhanced. New is the wp-settings.php line // Load in support for template functions which the theme supports require_if_theme_supports( &#039;post-thumbnails&#039;, ABSPATH . WPINC . &#039;/post-image-template.php&#039; ); In functions.php it queries whether the theme supports post-thumbnail function: if ( function_exists( &#039;add_theme_support&#039; ) ) add_theme_support( &#039;post-thumbnails&#039; ); If [...]]]></description>
			<content:encoded><![CDATA[<p>The new <a title="Article New feature in WordPress 2.9 – the_post_image()" href="http://wpengineer.com/new-feature-in-wordpress-2-9-the_post_image/"><strong> the_post_image</strong ></a> functionality in WordPress version 2.9 has been enhanced.<br />
New is the wp-settings.php line<br />
<span id="more-1779"></span></p>
<pre lang="php">
// Load in support for template functions which the theme supports
require_if_theme_supports( &#039;post-thumbnails&#039;, ABSPATH . WPINC . &#039;/post-image-template.php&#039; );
</pre>
<p>In functions.php it queries whether the theme supports post-thumbnail function:</p>
<pre lang="php">
if ( function_exists( &#039;add_theme_support&#039; ) )
	add_theme_support( &#039;post-thumbnails&#039; );
</pre>
<p>If you look at the file wp-includes/post-image-template.php, there are 4 new features:</p>
<ul>
<li><strong>has_post_image()</strong></li>
<li><strong>get_post_image_id()</strong></li>
<li><strong>the_post_image()</strong></li>
<li><strong>get_the_post_image()</strong></li>
</ul>
<p>The theme itself can check within the loop, if the post has a Post-Thumbnail, and if so, then it can be output:</p>
<pre lang="php">
&lt;?php if ( has_post_image() ) : ?&gt;
	&lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_post_image( array( 75, 75 ), array( &#039;class&#039; =&gt; &#039;alignleft&#039; ) ); ?&gt;&lt;/a&gt;
&lt;?php endif; ?&gt;
</pre>
<p>Those interested in more features and information should check the file in WordPress 2.9: <code>wp-includes/post-image-template.php</code><br />
Especially the function: <code>get_the_post_image</code><br />
It allows to adjust the output by using hooks.<br />
In <code>get_the_post_image</code> the function <code>wp_get_attachment_image</code> get also used, what has been explained in detail in <a href="http://wpengineer.com/easier-better-solutions-to-get-pictures-on-your-posts/">this post just a few days ago</a>.</p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1779/wordpress-2-9-add_theme_support-and-has_post_image/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

