Topic: Video Thumbnails (WP-Plugin) Support

Just want to share my code for those who're in need.

I'm running a community with a video-section. Mostly videos hosted on blip.tv and vimeo are shown. I needed a solution to fetch thumbnails from my articles containing the embeded videos to be shown when viewing the video-category.

Yesterday I found this WP-plugin, it's called Video Thumbnails and can be found here: http://wordpress.org/extend/plugins/video-thumbnails/

I use the plugin together with the code I found here: http://www.arrastheme.com/forums/topic2 … based.html (post #4) - there, a custom field is used and you have to manually resize the thumbnail, so it's not really an "automatic" solution.
Here is my adapted code (arras/library/tapestries.php) - I'm using Arras 1.5.0.1. In tapestry.php at the very bottom search for

$postheader .= arras_get_thumbnail($tapestry . '-thumb');

and replace this line with following:

$video_thumbnail = get_video_thumbnail();
    if($video_thumbnail){ 
    $postheader .=  "<img src='" . $video_thumbnail . "' width='195' />"; }
    else 
    {
    $postheader .= arras_get_thumbnail($tapestry . '-thumb'); }

so finally the last lines of code in this file look like this:

/**
 * Helper function to display headers for certain tapestries.
 * @since 1.4.3
 */
function arras_generic_postheader($tapestry, $show_meta = false) {
    global $post;
    
    $postheader = '<div class="entry-thumbnails">';
    $postheader .= '<a class="entry-thumbnails-link" href="' . get_permalink() . '">';
    $video_thumbnail = get_video_thumbnail();
    if($video_thumbnail){ 
    $postheader .=  "<img src='" . $video_thumbnail . "' width='195' />"; }
    else 
    {
    $postheader .= arras_get_thumbnail($tapestry . '-thumb'); }
    
    if ($show_meta) {    
        $postheader .= '<span class="entry-meta"><span class="entry-comments">' . get_comments_number() . '</span>';
        $postheader .= '<abbr class="published" title="' . get_the_time('c') . '">' . get_the_time( get_option('date_format') ) . '</abbr></span>';
    }
    
    $postheader .= '</a>';

    $postheader .= '</div>';
    
    $postheader .= '<h3 class="entry-title"><a href="' . get_permalink() . '" rel="bookmark">' . get_the_title() . '</a></h3>';
    
    return $postheader;
}

/* End of file tapestries.php */
/* Location: ./library/tapestries.php */

In addition to that, I tweaked my archive.php (arras/archive.php) to display different categories in different displays (videos are displayed in "default" mode). This is important - if you use another "mode" (traditional or archive_display) you have to adjust the thumbnail-width in the tapestries.php in this line.

 $postheader .=  "<img src='" . $video_thumbnail . "' width='195' />"; }

So, if you install the Video Thumbnails plugin, just activate, write an article, embed a video (in the editor-window) from vimeo, youtube or blip.tv and save it.
After saving you will see the video-thumbnail and it's url somewhere on the right displayed in a widget (in my case the widget shows under "Featured Thumbnail"-widget. That's all. No need for uploading/downloading a thumbnail - just embed the video - that's it.

You can see a working example on my site: http://www.minemusig.at/blog/category/musigtv/

I'm not really a programmer, so no real support. For me, it works nice - hope it does for you, too - in case, say thank you  cool

Greetings,
Harald

Last edited by noizeburger (2011-01-14 19:53:35)

Thumbs up

Re: Video Thumbnails (WP-Plugin) Support

I am confused about this statement below:

"In addition to that, I tweaked my archive.php (arras/archive.php) to display different categories in different displays (videos are displayed in "default" mode). This is important - if you use another "mode" (traditional or archive_display) you have to adjust the thumbnail-width in the tapestries.php in this line."

Do you put this code "$postheader .=  "<img src='" . $video_thumbnail . "' width='195' />"; }" in your archive.php somewhere?

Thumbs up +1

Re: Video Thumbnails (WP-Plugin) Support

@fernandezp27

Hi and sorry for my late reply. First of all, due to an update of the Video Thumbnails Plugin my rewored code is not really needed anymore.
My archive.php is tweaked - look at my code (line 27 in my file) and compare with yours - then you will find the changes I made.

    <div id="archive-posts">
    <?php
    if (is_category(1)) {
              arras_render_posts( null, 'traditional');
              }
        elseif (is_category(71)) {
              arras_render_posts( null, 'default' );
               } 
       else {
              arras_render_posts( null, arras_get_option('archive_display') ); 
} ?>    
    <?php if(function_exists('wp_pagenavi')) wp_pagenavi(); else { ?>
        <div class="navigation clearfix">
            <div class="floatleft"><?php next_posts_link( __('Older Entries', 'arras') ) ?></div>
            <div class="floatright"><?php previous_posts_link( __('Newer Entries', 'arras') ) ?></div>
        </div>
    <?php } ?>
    </div><!-- #archive-posts -->

The

"$postheader .=  "<img src='" . $video_thumbnail . "' width='195' />"; }"

is related to tapestries. Just wanted you to know, that this is the line, where you set dimension of your displayed thumbnail. Got it?

Greetings

Thumbs up

4

Re: Video Thumbnails (WP-Plugin) Support

Moved this to Theme Guides.

Thanks for the heads up smile