Support » Plugin: Instant Articles for WP » Please add missing elements from Facebook SDK

  • Hi,

    I´m adding custom video as Cover, and managed to do so, but only when I modify the plugin core class.

    In class-instant-articles-post.php :

    Missing:

    use Facebook\InstantArticles\Elements\Video;

    In function to_instant_article() a simple check for Video could be added like this:

    $cover = $this->get_the_featured_image();
    		if ( $cover['src'] ) {
    			// Check if cover type is video / image
    			if ( $cover['type'] == 'video' ) {
    				$image = Video::create()->withURL( $cover['src'] );
    			} else {
    				$image = Image::create()->withURL( $cover['src'] );
    			}
    			if ( isset( $cover['caption'] ) && strlen( $cover['caption'] ) > 0 ) {
    				$image->withCaption(
    				    Caption::create()->withTitle( $cover['caption'] )
    				);
    			}
    
    			$header->withCover( $image );
    		}

    Then its possible to modify the preferred output of video or image with a filter to hook into instant_articles_featured_image()

    https://wordpress.org/plugins/fb-instant-articles/

  • The topic ‘Please add missing elements from Facebook SDK’ is closed to new replies.