WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Viper's Video Quicktags] Suggestion: fallback content with img also for youtube playlist (4 posts)

  1. francescolaffi
    Member
    Posted 4 years ago #

    The fallback content of youtube videos include a thumbnail, I would like to have it also for youtube playlists.
    I know it takes more resource to get a thumb for a playlist, so maybe it would be an option, what viper thinks about it?

    Just in case I leave here a function that get the thumb of the first video of the playlist for a given playlist_id, I use it in a video gallery section of my site.

    function youtube_playlist_thumb_test($playlist_id){
    	$api_url = 'http://gdata.youtube.com/feeds/api/playlists/'.$playlist_id;
    	$request = new WP_Http;
    	$result = $request->request( $api_url );
    	if ($result['response']['code'] == 200) {
    		$parser = xml_parser_create();
    		$vals = array();
    		$index = array();
    		xml_parse_into_struct($parser, $result['body'], $vals, $index);
    		xml_parser_free($parser);
    		if (count($vals)) {
    			foreach ($vals as $val) {
    				if ($val['tag'] == 'MEDIA:THUMBNAIL' && $val['attributes']['HEIGHT'] == '240') {
    					return $val['attributes']['URL'];
    					break;
    				}
    			}
    		}
    	}
    	return false;
    }

    I adapted it from this http://drupal.org/files/issues/playlist_0.patch

    http://wordpress.org/extend/plugins/vipers-video-quicktags/

  2. I wasn't planning on using placeholders in the new version of my plugin as the new version won't require Javascript, however they may be a good placeholder for people without Flash (say iPhones).

    I'll make sure to set aside your code. It'll be a good starting point for playlist thumbs (needs caching for example). Thanks. :)

  3. francescolaffi
    Member
    Posted 4 years ago #

    Thanks for your replay.
    Caching is a good point, maybe I should use it for the results I get from the requests in the custom video gallery section of my site.
    Should I use wp object caching or transient API (or something else)? I don't know anything about caching, any suggestion would be appreciated.

    Thanks
    Francesco

  4. WordPress' object caching isn't persistent (page-to-page) unless you install a file that makes it so and stores it to memcache, etc.

    Best to use the transient API or a single option (depends on cache size).

Topic Closed

This topic has been closed to new replies.

About this Topic