Recent Topics

1 May 03, 2014 17:52    

Hi
I want to get thumbnails of video (mostly youtube and vimeo) in the post excerpt on my homepage. Can anyone suggest a way of achieving this please? Achillis has suggested the solution might lie with the video plugin. Many thanks, mojo.

2 May 11, 2014 06:20

Any thoughts on this? The only thing I can think of is saving youtube/vimeo images and attaching them to posts so that they can go in the excerpt - but then they would show up in the post itself. Also this would be so laborious that I wouldn't want to post any videos. There is a wordpress plugin that does this so I guess it's possible in b2evo? cheers.

3 May 11, 2014 11:57

I guess it is not implemented in b2evo, but a workaround could be done by using custom fields and hacking the _rss2 skin. I mean, it's possible to retrieve the thumbnails URL from youtube or vimeo by making API calls and processing the answer before to display the excerpts.

But, just to confirm before to suggest something more specific, are you talking about to include the thumbnails in the excerpt to be displayed in RSS feeds? How do you think this feature should work? What if your post has more than one video? Which is the WP plugin that you mentioned?

Thanks.

5 May 13, 2014 07:20

All right @mojolazarus, now I clearly undertsand what you want. It would be nice to have a plugin that automatically extract the thumbnail from a video, and as you said, the videoplug plugin should be the right place to do it. Perhaps a developer cheers up to work on this in the near future.

In the meantime, I suggest this workaround: custom field + customized skin. I will try to share this as clear as possible in order to be useful for you.

1) Create a custom field (http://b2evolution.net/man/item-custom-fields) named video_thumb (see screenshot_01 above).
2) Copy/Paste the new methods into the *_Skin class at the _skin.class.php file of your skin. You could find those methods after the section New methods in the attached file _skin.class.php.zip.
3) Copy/Paste the code block below starting at line 111. I'm working with the evoPress skin, but you can adapt it to your own skin, just consider that the block should be put at the beginning of this cycle while( $Item = & mainlist_get_item() ) {

File: blogs/skins/evopress/post.main.php


$excerpt_before_text = '<div class="excerpt">';

	if( $Item->video_thumb = $Item->get_custom_field_value( 'video_thumb' ) )
	{
		if($thumb_url = $Skin->decode_tag($Item->video_thumb))
		{
			$excerpt_before_text .= '<img src="'.$thumb_url.'" style="float: left;">';
		}
	}
	// ---------------------- ITEM BLOCK INCLUDED HERE ------------------------
	skin_include( '_item_block.inc.php', array(
			'content_mode' => 'excerpt',		// 'auto' will auto select depending on $disp-detail
			'image_size'	 =>	'fit-400x320',
			'excerpt_before_text' => $excerpt_before_text,
		) );
	// ----------------------------END ITEM BLOCK  ----------------------------

4) Go to the edition form of the post.
5) Copy/Paste the entire video tag in the custom field Video thumb (see screenshot_02).

This will only work for youtube and vimeo videos, but it could be easily extended for more providers.

Please, let me know what do you think.

Regards!


Attachments:

6 May 13, 2014 22:12

This looks awesome, thanks so much of taking the time. I will give it a go over the next few days and post back to tell you how it went. Cheers.

7 May 15, 2014 20:05

So thanks again for this mgsolipa, I have got it to work and it isn't much hassle to add the video id to the custom field when you are about to post. One problem I had, though, was an error saying constant 'YT_API_URL' is already defined. This happens when you have completed one post and move to a second. The second time you apply a video code to the custom field (i.e. a second, different post) you get the 'already defined error'. I guess it is held in memory or something? Anyway I added:
if (defined('YT_API_URL')) define('YT_API_URL', 'http://gdata.youtube.com/feeds/api/videos?q=');
define('YT_API_URL', 'http://gdata.youtube.com/feeds/api/videos?q=');
to experiment. Doesn't seem very efficient or quite right though. Am I on the wrong track?
This allowed me to see thumbnails but I still got the errors, e.g.:
Notice: Constant YT_API_URL already defined in .../skins/chileno/_skin.class.php on line 109

Notice: Constant YT_API_URL already defined in .../skins/chileno/_skin.class.php on line 110

line 109 and 110 are where the define statements are.

Thanks again.

8 May 15, 2014 20:59

I think that should be, more simply:
if (!defined('YT_API_URL')) define('YT_API_URL', 'http://gdata.youtube.com/feeds/api/videos?q=');
and:
if (!defined('VM_API_URL'))define('VM_API_URL', 'http://vimeo.com/api/v2/video/');

I'm testing it now...

9 May 16, 2014 14:25

So, just to say thanks and that using those if statements worked for me, if anyone else wants to use mgsolipa's workaround. There has to be some text in the excerpt for it to work. The 'video thumb' text that shows up in the post I guess could be 'painted' the same colour as the background to make it invisible and I might try and add a link from the thumbnail to the post. Here's a category list showing what it looks like on my site:
http://chileno.co.uk/track-of-the-day
I might try and add something for other services (e.g.sound cloud and tedtalks) although I'm not a coder. As mgsolipa says it might be something a developer could do.

All the best.

10 Jun 11, 2015 01:23

The original patch doesn't work anymore for Youtube videos.

You still can follow the steps described here: http://forums.b2evolution.net/video-thumbnail-in-excerpt#c102378. Except step 2, in which you should copy & paste the methods from here: https://gist.github.com/mgsolipa/cbb3ad0ffa5e84553a5c, instead of from the file attached to the mentioned comment.

Please, also consider that this code won't work in b2evolution version 6. So, I will post a new update soon.

Thank you.


Form is loading...