<?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>Friendly (blog)</title>
	<atom:link href="http://blog.friendlywebconsulting.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.friendlywebconsulting.com</link>
	<description>The somewhat official blog of Friendly Web Consulting</description>
	<lastBuildDate>Sat, 26 Apr 2014 20:34:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.2</generator>
	<item>
		<title>Display WordPress featured image, thumbnail, or YouTube thumb</title>
		<link>http://blog.friendlywebconsulting.com/2013/02/display-wordpress-featured-image-thumbnail-or-youtube-thumb/</link>
		<comments>http://blog.friendlywebconsulting.com/2013/02/display-wordpress-featured-image-thumbnail-or-youtube-thumb/#comments</comments>
		<pubDate>Thu, 14 Feb 2013 03:24:22 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[WordPress Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=177</guid>
		<description><![CDATA[Huge thanks to Vladimir Prelovac, who wrote the original function. I use it a ton and have adapted it a bit to check for: Featured image; then First image attached to the post; then The first image inserted in the post; then The thumbnail of the first YouTube video inserted in the post All I added [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Huge thanks to Vladimir Prelovac, who wrote <a href="http://www.prelovac.com/vladimir/simple-wordpress-thumbnail-function">the original function</a>. I use it a ton and have adapted it a bit to check for:</p>
<ol>
<li>Featured image; then</li>
<li>First image attached to the post; then</li>
<li>The first image inserted in the post; then</li>
<li>The thumbnail of the first YouTube video inserted in the post</li>
</ol>
<p>All I added was the featured image bit. <img src="http://blog.friendlywebconsulting.com/logmeinplz/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p>Here&#8217;s the full function, plus 3 helper functions, which should all be inserted in your theme&#8217;s functions.php file:</p>
<ul>
<li>[UPDATED 2013.03.09 to return correct size for inserted images AND to allow for the function to return the featured-image only. This baby is getting long, let me know if you find a way to hone it down!]</li>
</ul>
<pre class="brush: php; gutter: true; first-line: 1">/**** 
IMAGE PARSING FUNCTIONS 
****/

/** HELPER FUNCTION 1: **/
// GET YOUTUBE ID FROM URL
// see http://webgarb.com/tutorials/how-to-get-youtube-video-id-from-url-perfect-way/
function youtubeID($url){
     $res = explode("v=",$url);
     if(isset($res[1])) {
        $res1 = explode('&amp;',$res[1]);
        if(isset($res1[1])){
            $res[1] = $res1[0];
        }
        $res1 = explode('#',$res[1]);
        if(isset($res1[1])){
            $res[1] = $res1[0];
        }
     }
     return substr($res[1],0,12);
     return false;
}

/*** HELPER FUNCTION 2: ***/
// FIND YOUTUBE URLS IN CONTENT AND CONVERT TO SIMPLE FORMAT
// adapted from answer here: http://stackoverflow.com/a/5831191/107244 
function parseYouTubeURLs($mm_text) {
    $mm_text = preg_replace('~
        # Match non-linked youtube URL in the wild. (Rev:20111012)
        https?://         # Required scheme. Either http or https.
        (?:[0-9A-Z-]+\.)? # Optional subdomain.
        (?:               # Group host alternatives.
          youtu\.be/      # Either youtu.be,
        | youtube\.com    # or youtube.com followed by
          \S*             # Allow anything up to VIDEO_ID,
          [^\w\-\s]       # but char before ID is non-ID char.
        )                 # End host alternatives.
        ([\w\-]{11})      # $1: VIDEO_ID is exactly 11 chars.
        (?=[^\w\-]|$)     # Assert next char is non-ID or EOS.
        [?=&amp;+%\w-]*        # Consume any URL (query) remainder.
        ~ix', 
        'http://www.youtube.com/watch?v=$1',
        $mm_text);
    return $mm_text;
}

/*** HELPER FUNCTION 3: ***/
// GET ATTACHMENT ID
// see http://wordpress.stackexchange.com/a/7094
if ( ! function_exists( 'get_attachment_id' ) ) {
    /**
     * Get the Attachment ID for a given image URL.
     *
     * @link   http://wordpress.stackexchange.com/a/7094
     *
     * @param  string $url
     *
     * @return boolean|integer
     */
    function get_attachment_id( $url ) {

        $dir = wp_upload_dir();

        // baseurl never has a trailing slash
        if ( false === strpos( $url, $dir['baseurl'] . '/' ) ) {
            // URL points to a place outside of upload directory
            return false;
        }

        $file  = basename( $url );
        $query = array(
            'post_type'  =&gt; 'attachment',
            'fields'     =&gt; 'ids',
            'meta_query' =&gt; array(
                array(
                    'value'   =&gt; $file,
                    'compare' =&gt; 'LIKE',
                ),
            )
        );

        $query['meta_query'][0]['key'] = '_wp_attached_file';

        // query attachments
        $ids = get_posts( $query );

        if ( ! empty( $ids ) ) {

            foreach ( $ids as $id ) {

                // first entry of returned array is the URL
                if ( $url === array_shift( wp_get_attachment_image_src( $id, 'full' ) ) )
                    return $id;
            }
        }

        $query['meta_query'][0]['key'] = '_wp_attachment_metadata';

        // query attachments again
        $ids = get_posts( $query );

        if ( empty( $ids) )
            return false;

        foreach ( $ids as $id ) {

            $meta = wp_get_attachment_metadata( $id );

            foreach ( $meta['sizes'] as $size =&gt; $values ) {

                if ( $values['file'] === $file &amp;&amp; $url === array_shift( wp_get_attachment_image_src( $id, $size ) ) )
                    return $id;
            }
        }

        return false;
    }
}

/*** MAIN FUNCTION, GET THUMBNAIL ***/
// Your theme must support post thumbnails for this function to work. If you are getting an error try adding add_theme_support('post-thumbnails'); to your functions.php file 
// NOTE: If $feature is set to true, the image will only be returned if it is set as a featured image.
function vp_get_thumb_url($text, $size, $feature = false) {
    global $post;
    $imageurl="";

    // Check to see which image is set as "Featured Image"
    $featuredimg = get_post_thumbnail_id($post-&gt;ID);
    // Get source for featured image
    $img_src = wp_get_attachment_image_src($featuredimg, $size);
    // Set $imageurl to Featured Image
    $imageurl = $img_src[0];

    // if not returning only the featured image, move on and get something else
    if ($feature == false) {

        // If there is no "Featured Image" set, move on and get the first image attached to the post
        if (!$imageurl) {
            // Extract the thumbnail from the first attached imaged
            $allimages =&amp;get_children('post_type=attachment&amp;post_mime_type=image&amp;post_parent=' . $post-&gt;ID );

            foreach ($allimages as $img){
                $img_src = wp_get_attachment_image_src($img-&gt;ID, $size);
                break;
            }
            // Set $imageurl to first attached image
            $imageurl=$img_src[0];
        }

        // If there is no image attached to the post, look for anything that looks like an image and get that
        if (!$imageurl) {
            preg_match('/&lt;\s*img [^\&gt;]*src\s*=\s*[\""\']?([^\""\'&gt;]*)/i' , $text, $matches);
            $imageurl=$matches[1];

            // get image ID - uses helper function get_attachment_id() )
            $image_id = get_attachment_id($imageurl);

            // retrieve the relevant size of our image
            $image_src = wp_get_attachment_image_src($image_id, $size);

            // set $imageurl to first inserted image
            $imageurl = $image_src[0];
        }

        // YOUTUBE
        // If there's no image attached or inserted in the post, look for a YouTube video
        if (!$imageurl) {

            // FIND FIRST YOUTUBE URL IN CONTENT
            // uses helper function parseYouTubeURLs
            $youtubeurl = parseYouTubeURLs($text);

            // GET YOUTUBE ID FROM URL
            // users helper function youtubeID();
            $videokey = youtubeID($youtubeurl);

            if ($videokey) {
                // Get the thumbnail YouTube automatically generates
                // '0' is the biggest version, use 1 2 or 3 for smaller versions
                $imageurl = "http://i.ytimg.com/vi/{$videokey}/0.jpg";
            }
        }

        // DEFAULT IMAGE
        // if there's no image or embedded YouTube, show a default image
        if (!$imageurl) {

        }

    } // feature = false

    // Spit out the image path
    return $imageurl;
}
/*** END FEATURED IMAGE PARSING FUNCTIONS ***/</pre>
<p>And to display the image in your theme, often on archive.php or index.php within the loop, add this:</p>
<pre class="brush: php; gutter: true; first-line: 1">// Show featured image, or first image if no featured, or YouTube thumbnail
if (function_exists('vp_get_thumb_url')) {

	// Set the desired image size. Swap out 'thumbnail' for 'medium', 'large', or custom size
	$thumb=vp_get_thumb_url($post-&gt;post_content, 'thumbnail');

	if ($thumb!='') { ?&gt;

		&lt;a href="&lt;?php the_permalink() ?&gt;" title="&lt;?php the_title(); ?&gt;" rel="bookmark"&gt;&lt;img class="alignleft" src="&lt;?php echo $thumb; ?&gt;" alt="&lt;?php get_the_title(); ?&gt;" /&gt;&lt;/a&gt;

	&lt;?php }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2013/02/display-wordpress-featured-image-thumbnail-or-youtube-thumb/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Add post/page name + page parent name to body class</title>
		<link>http://blog.friendlywebconsulting.com/2011/07/add-page-and-parent-name-to-body-class/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/07/add-page-and-parent-name-to-body-class/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 16:17:22 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[WordPress Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=192</guid>
		<description><![CDATA[This will add a page-slug class and a page-parent-slug class to your body tag, along with all the other defaults. Put this in your functions.php file: Also make sure your open body tag looks like this (you can probably find it in header.php): Many thanks to Utkarsh Kuketri for the original function!]]></description>
				<content:encoded><![CDATA[<p>This will add a page-slug class and a page-parent-slug class to your body tag, along with all the other defaults. Put this in your functions.php file:</p>
<pre class="brush: php; title: ; notranslate">
function wpprogrammer_post_name_in_body_class( $classes ){
if( is_singular() ) {
     global $post;
     $parent = get_page($post-&gt;post_parent);
     array_push( $classes, &quot;{$post-&gt;post_type}-{$post-&gt;post_name}&quot; );
     array_push( $classes, &quot;{$post-&gt;post_type}-parent-{$parent-&gt;post_name}&quot; );
     }
return $classes;
}
add_filter( 'body_class', 'wpprogrammer_post_name_in_body_class' );
</pre>
<p>Also make sure your open body tag looks like this (you can probably find it in header.php):</p>
<pre class="brush: php; title: ; notranslate">

&lt;body &lt;?php body_class(); ?&gt;&gt;

</pre>
<p>Many thanks to <a href="http://wpprogrammer.com/snippets/add-post-page-name-to-body-class/">Utkarsh Kuketri</a> for the original function!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/07/add-page-and-parent-name-to-body-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Talk about handy! One Page Apps &#124; CSS-Tricks</title>
		<link>http://blog.friendlywebconsulting.com/2011/06/talk-about-handy-one-page-apps-css-tricks/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/06/talk-about-handy-one-page-apps-css-tricks/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 03:34:40 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[General Web Coolness]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=173</guid>
		<description><![CDATA[I&#8217;ve used CSS3Please a tone, but many of the others are new to me &#8211; and so handy! I love CSS-Tricks.com. http://css-tricks.com/12389-one-page-apps-i-actually-use/]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve used CSS3Please a tone, but many of the others are new to me &#8211; and so handy! I love CSS-Tricks.com. <img src="http://blog.friendlywebconsulting.com/logmeinplz/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>
<p><a href="http://css-tricks.com/12389-one-page-apps-i-actually-use/">http://css-tricks.com/12389-one-page-apps-i-actually-use/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/06/talk-about-handy-one-page-apps-css-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Techniques for Customizing the WordPress Admin Panel</title>
		<link>http://blog.friendlywebconsulting.com/2011/04/10-techniques-for-customizing-the-wordpress-admin-panel/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/04/10-techniques-for-customizing-the-wordpress-admin-panel/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 20:31:22 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[WordPress Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=168</guid>
		<description><![CDATA[Great article from Six Revisions with lots of tips to customize both the dashboard and entire WordPress control panel.]]></description>
				<content:encoded><![CDATA[<p><a href="http://sixrevisions.com/wordpress/10-techniques-for-customizing-the-wordpress-admin-panel/">Great article from Six Revisions</a> with lots of tips to customize both the dashboard and entire WordPress control panel.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/04/10-techniques-for-customizing-the-wordpress-admin-panel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stack Exchange-like voting for WordPress</title>
		<link>http://blog.friendlywebconsulting.com/2011/03/stack-exchange-plugin/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/03/stack-exchange-plugin/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 20:03:18 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[WordPress Tips & Tricks]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=161</guid>
		<description><![CDATA[Finally, a StackExchange-like plugin for WordPress! I haven&#8217;t used it yet but CubePoints looks very promising.]]></description>
				<content:encoded><![CDATA[<p>Finally, a StackExchange-like plugin for WordPress! I haven&#8217;t used it yet but <a href="http://wordpress.org/extend/plugins/cubepoints/">CubePoints</a> looks very promising.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/03/stack-exchange-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validation as you type</title>
		<link>http://blog.friendlywebconsulting.com/2011/03/validation-as-you-type/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/03/validation-as-you-type/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 18:48:11 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[Web Design Insights]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=157</guid>
		<description><![CDATA[An interesting article from UXExchange on validating forms as a user fills them out.]]></description>
				<content:encoded><![CDATA[<p><a href="http://uxmovement.com/forms/how-instant-validation-can-speed-up-long-forms">An interesting article from UXExchange</a> on validating forms as a user fills them out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/03/validation-as-you-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TwentyTen Five &#8211; The HTML5 WordPress theme</title>
		<link>http://blog.friendlywebconsulting.com/2011/02/use-html5-in-wordpress-twentyten-twentyten-five-the-html5-wordpress-theme/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/02/use-html5-in-wordpress-twentyten-twentyten-five-the-html5-wordpress-theme/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 22:21:42 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[WordPress Tips & Tricks]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=141</guid>
		<description><![CDATA[A very good Smashing Magazine article came out the other day explaining how to convert the WordPress TwentyTen theme to HTML5. Here&#8217;s that theme for download: http://www.twentytenfive.com/]]></description>
				<content:encoded><![CDATA[<p>A very good <a href="http://www.smashingmagazine.com/2011/02/22/using-html5-to-transform-wordpress-twentyten-theme/">Smashing Magazine article</a> came out the other day explaining how to convert the WordPress TwentyTen theme to HTML5. Here&#8217;s that theme for download:</p>
<p><a href="http://www.twentytenfive.com/">http://www.twentytenfive.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/02/use-html5-in-wordpress-twentyten-twentyten-five-the-html5-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Daily Tip: Add More Automatic Image Sizes to the WordPress Media Library</title>
		<link>http://blog.friendlywebconsulting.com/2011/02/daily-tip-add-more-automatic-image-sizes-to-the-wordpress-media-library/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/02/daily-tip-add-more-automatic-image-sizes-to-the-wordpress-media-library/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 21:30:26 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[WordPress Tips & Tricks]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[media]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=136</guid>
		<description><![CDATA[Great tip from the WPMU blog, and one I&#8217;d been seeking for a while. This gives you the ability to not only add new image sizes, but to have them show up in the Media popover so that users can &#8220;Insert (the new image size) into Post&#8221;. http://networkedblogs.com/eCP0w]]></description>
				<content:encoded><![CDATA[<p>Great tip from the WPMU blog, and one I&#8217;d been seeking for a while. This gives you the ability to not only add new image sizes, but to have them show up in the Media popover so that users can &#8220;Insert (the new image size) into Post&#8221;. <a href="http://networkedblogs.com/eCP0w">http://networkedblogs.com/eCP0w</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/02/daily-tip-add-more-automatic-image-sizes-to-the-wordpress-media-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Variables with PHP &#124; CSS-Tricks</title>
		<link>http://blog.friendlywebconsulting.com/2011/02/css-variables-with-php-css-tricks/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/02/css-variables-with-php-css-tricks/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 19:01:04 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[General Web Coolness]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=132</guid>
		<description><![CDATA[Awesome trick enabling you to use variables in CSS files. Would be great for themes with user-selectable style elements. http://css-tricks.com/css-variables-with-php/]]></description>
				<content:encoded><![CDATA[<p>Awesome trick enabling you to use variables in CSS files. Would be great for themes with user-selectable style elements.</p>
<p><a href="http://css-tricks.com/css-variables-with-php/">http://css-tricks.com/css-variables-with-php/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/02/css-variables-with-php-css-tricks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JQuery Sliders</title>
		<link>http://blog.friendlywebconsulting.com/2011/02/jquery-sliders/</link>
		<comments>http://blog.friendlywebconsulting.com/2011/02/jquery-sliders/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 05:17:27 +0000</pubDate>
		<dc:creator><![CDATA[Michelle McGinnis]]></dc:creator>
				<category><![CDATA[General Web Coolness]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://blog.friendlywebconsulting.com/?p=105</guid>
		<description><![CDATA[Some good sliders, including the WOW slider I&#8217;d like to try out when I next have the chance: http://plugins.jquery.com/projects/plugins?type=48]]></description>
				<content:encoded><![CDATA[<p>Some good sliders, including the WOW slider I&#8217;d like to try out when I next have the chance: <a href="http://plugins.jquery.com/projects/plugins?type=48">http://plugins.jquery.com/projects/plugins?type=48</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.friendlywebconsulting.com/2011/02/jquery-sliders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
