WordPress.org

Ready to get started?Download WordPress

Forums

Simple Facebook Connect
Publish to Fan Page doesn't include preview (8 posts)

  1. DoubiTchou
    Member
    Posted 3 years ago #

    Hi Otto,

    First, i want to give you all my consideration for this plugin. There is very usefull. Thx a lot for your hard working !

    So, i have traveled all the forum, and i have find no answer to my reclamation...

    My blog, use your plugin to push automaticaly post on facebook fan page. All works good since 4 months, but my blog is a specific media blog. When i post, i post comments (some word) and a flash media code. It's finally a video blog.

    When i publish a post with a flash media youtube code, i have got only comment on my fan page...
    But if i publish manually this same post on my facebook page, i've got a preview screenshot of vidéo.

    I can give you some exemple if you don't understand my problem ;)

    Sorry for my english, i am a french guy ;)

    Cya

    DoubiTchou.com

  2. DoubiTchou
    Member
    Posted 3 years ago #

    no Reply ? :( up!

  3. Samuel Wood (Otto)
    Tech Ninja
    Plugin Author

    Posted 3 years ago #

    I understand the problem. I just don't have any answer for you.

    The simple answer is yes. You are correct. SFC-Publish does not support video at present.

    This is unlikely to change any time soon.

  4. mobius509
    Member
    Posted 3 years ago #

    Hi Otto, i was playing around with trying to get video to embed with the play button beside it when i make a post through this plugin. I've been digging around and driving myself absolutely mad. Embedding meta data into the post... anything that might actually make it pick up the video but no luck.

    Finally stumbled on this comment. Is it true that it just doesn't work and there's no chance it will work in the future? Seems like something that would be part of this plugin as a matter of course. Just wondering if that's the case why that is?

    Might mean i'll have to change plugins. Let me know. Thanks for all your hard work on this, made the whole thing so much easier to integrate.

  5. Samuel Wood (Otto)
    Tech Ninja
    Plugin Author

    Posted 3 years ago #

    No, it doesn't do video at the moment. No plans to change this.

    You could make it do it, if you know the format of the video and added the proper header information. But without knowing specific details about the video, having code to extract the video URL from the system, etc, you're not going to make it magically able to guess what the video in the page is.

  6. mobius509
    Member
    Posted 3 years ago #

    Thanks Otto. I kinda hacked in my own support for it. It wasn't so bad when i stuck with the idea of having a specific embed code to make it know it's video. It's a really bad hack but it does the trick. You still have to manually put in all the info though.

    // look for the images to add with image_src
    	$images = array();
    	$videos = array();
    	$isVideo = false;
    
    	// get the post thumbnail, put it first in the image list
    	if (current_theme_supports('post-thumbnails')) {
    		if ( has_post_thumbnail($post->ID) ) {
    			$thumbid = get_post_thumbnail_id($post->ID);
    			$att = wp_get_attachment_image_src($thumbid, 'full');
    			if (!empty($att[0])) $images[] = $att[0];
    		}
    	}
    
    	// build the attachment
    	$permalink = apply_filters('sfc_publish_permalink',get_permalink($post->ID),$post->ID);
    	$attachment['name'] = $post->post_title;
    	$attachment['href'] = $permalink;
    	$attachment['description'] = sfc_publish_make_excerpt($post->post_content);
    	//$attachment['comments_xid'] = urlencode($permalink);
    
    	// look for any videos in the content
    	if ( preg_match_all('/<link rel="video_src" (.+?)>/i', $content, $matches) ) {
    		foreach ($matches[1] as $match) {
    			foreach( wp_kses_hair($match, array('http')) as $attr) {
    				$vid[strtolower($attr['name'])] = $attr['value'];
    			}
    			if ( isset($vid['swfsrc']) || isset($vid['imgsrc'])) {
    				$videos[] = array($vid['swfsrc'], $vid['imgsrc']);
    				//echo ">>>>>>>>>>>>>>>>>>>>>>> 1 ", $videos[0][0] , " 2 ", $vid['swfsrc'];
    				//	echo ">>>>>>>>>>>>>>>>>>>>>>> 1 ", $videos[0][1] , " 2 ", $vid['imgsrc'];
    			}
    		}
    		$isVideo = true;
    	}
    
    	if ($isVideo == false)
    	{
    		// look for any images in the content
    		if ( preg_match_all('/<img (.+?)>/i', $content, $matches) ) {
    			foreach ($matches[1] as $match) {
    				foreach ( wp_kses_hair($match, array('http')) as $attr) {
    					$img[strtolower($attr['name'])] = $attr['value'];
    				}
    				if ( isset($img['src']) ) {
    					if (!isset($img['class']) ||
    						(isset($img['class']) && false === straipos($img['class'], apply_filters('sfc_img_exclude',array('wp-smiley'))))
    						) { // ignore smilies
    						$images[] = $img['src'];
    					}
    				}
    			}
    		}
    	}
    
    	$count=0;
    	if ($isVideo)
    	{
    		foreach ($videos as $video) {
    			$attachment['media'][$count]['type'] = 'flash';
    			$attachment['media'][$count]['swfsrc'] = $videos[$count][0];
    			$attachment['media'][$count]['imgsrc'] = $videos[$count][1];
    			$attachment['media'][$count]['href'] = $permalink;
    			break;
    		}
    	} else {
    		// image attachments (up to 5, as that's all FB allows)
    		foreach ($images as $image) {
    			$attachment['media'][$count]['type'] = 'image';
    			$attachment['media'][$count]['src'] = $image;
    			$attachment['media'][$count]['href'] = $permalink;
    			$count++; if ($count==5) break;
    		}
    	}

    I changed all that then in the posts that contain video i have to add in a link tag that will embed the video.

    <link rel="video_src" href="http://www.youtube.com/watch?v=-4VFeYZTTYs" swfsrc="http://www.youtube.com/v/-4VFeYZTTYs?fs=1&hl=en_US" imgsrc="http://i.ytimg.com/vi/-4VFeYZTTYs/0.jpg"/>

    Obviously an intense hack. But it does do the trick. Thanks for your reply. Any reason you're not thinking of adding video in?

  7. mobius509
    Member
    Posted 3 years ago #

    For anybody looking at what i just posted please note that i am not a PHP/HTML guy and this code probably isn't all that recommended to use. It's not all that elegant. It's not even using HTML that will validate properly. As i said multiple times it's a hack.

  8. Anonymous
    Unregistered
    Posted 3 years ago #

    I found an even simpler solution that I would like to run across anyone who is interested. Add this code before // build the attachment

    if ( preg_match_all('/(?<=http:\/\/www.youtube.com\/v\/)(.*?)(?=\?)/', $content, $matches) )
    	{
    			$images[] = "http://img.youtube.com/vi/" . $matches[0][0] . "/0.jpg";
    	}

    It captures the thumbnail image Youtube creates for videos and adds it to the image stream that is posted to Facebook. That is all the code I added and I am not familiar with PHP so it may be error prone. I have tried to break it but I couldn't.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic