How do I insert Vimeo img thumbnails from Vimeo on my website?
snippet:
<?php
/**
* snippet VidLister <VidLister>
*/
$modx->getService('vidlister','VidLister',$modx->getOption('vidlister.core_path',null,$modx->getOption('core_path').'components/vidlister/').'model/vidlister/',$scriptProperties);
$modx->lexicon->load('vidlister:default');
//settings
$tpl = $modx->getOption('tpl', $scriptProperties, '{"youtube":"vlYoutube","vimeo":"vlVimeo"}');
$scripts = $modx->getOption('scripts', $scriptProperties, '1');
$sortby = $modx->getOption('sortby', $scriptProperties, 'created');
$sortdir = $modx->getOption('sortdir', $scriptProperties, 'DESC');
// 2013-03-01 ????????? ??????? ?????? topic
$topic = $_GET["topic"]?(int)$_GET["topic"]:0;
//template per source set using JSON
$tpls = $modx->fromJSON($tpl);
$where = $modx->getOption('where', $scriptProperties, '');
$where = !empty($where) ? $modx->fromJSON($where) : array();
if (!empty($topic)) $where["topic"]=$topic; // ??????? 2013-03-01
//getPage setings
$limit = $modx->getOption('limit', $scriptProperties, 10);
$offset = $modx->getOption('offset', $scriptProperties, 0);
$totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
if (in_array(strtolower($sortby),array('random','rand()','rand'))) {
$sortby = 'RAND()';
$sortdir = '';
}
if($scripts)
{
$modx->regClientStartupHTMLBlock('<link rel="stylesheet" type="text/css" href="/assets/components/vidlister/js/web/prettyphoto/css/prettyPhoto.css" />');
$modx->regClientStartupScript('/assets/components/vidlister/js/web/prettyphoto/js/jquery.prettyPhoto.js');
$modx->regClientStartupHTMLBlock('<script type="text/javascript">
$(document).ready(function(){
$("a[rel^=\'prettyPhoto\']").prettyPhoto({
autoplay: true,social_tools: \'\'
});
});
</script>');
}
$output = '';
$c = $modx->newQuery('vlVideo');
//criteria
if (!empty($where)) {
$c->where($where);
}
$c->andCondition(array('active' => 1));
//set placeholder for getPage
$modx->setPlaceholder($totalVar, $modx->getCount('vlVideo', $c));
$c->sortby($sortby, $sortdir);
$c->limit($limit, $offset);
$idx = 0; //index
$videos = $modx->getCollection('vlVideo', $c);
foreach($videos as $video)
{
//$video2 = $video->toArray();
$duration = $video->duration();
$video = $video->toArray();
// print_r($video);die;
$source = $video['source'];
$videoId = $video['videoId'];
$video['duration'] = $duration;
$filename=$modx->getOption('assets_url').'components/vidlister/images/'.$video['id'].'.jpg';
if (!file_exists($filename)) {
$filename="http://img.youtube.com/vi/$videoId/0.jpg";
}
$video['image'] = $filename;
$video['idx'] = $idx; //index
if(isset($tpls[$source]))
{
$output .= $modx->getChunk($tpls[$source], $video);
}
else
{
$output .= $modx->getChunk($tpl, $video);
}
$idx++;
}
return $output;
Chunk:
<li> <a href="http://player.vimeo.com/video/[[+videoId]]" class="video colorbox_vimeo" rel="" title="[[+name:html]]"><img src="[[+image]]"><alt="[[+name:html]]" /></a> <div class="meta"> <span> [[+created:date=`%d.%m.%Y`]] </span> <span class="pull-right"> /[[+duration.hh]]:[[+duration.mm]]:[[+duration.ss]] ([[+duration.seconds]] ???.)/ </span> </div> <h4><a href="#">[[+name:html]]</a></h4> </li>
This looks like copied YouTube code, yes?
I'm not going to rewrite that Vidlister library... but here's what you can do:
Use the developer API at Vimeo. Picking a video at random https://developer.vimeo.com/api/playground/videos/23895916
You'll see a JSON section for pictures
So using those sizes you can copy the one(s) you want to your server.