/**
  * @param Content $content
  *
  * @return \Illuminate\View\View
  */
 public function chooseThumbnail($content)
 {
     if (!$content->canEdit(user())) {
         return redirect()->route('content_comments', $content->getKey())->with('danger_msg', 'Minął czas dozwolony na edycję treści.');
     }
     try {
         $thumbnails = \OEmbed::getThumbnails($content->url);
     } catch (\Exception $e) {
         $thumbnails = [];
     }
     $thumbnails[] = 'http://img.bitpixels.com/getthumbnail?code=74491&size=200&url=' . urlencode($content->url);
     session(compact('thumbnails'));
     return view('content.thumbnails', compact('content', 'thumbnails'));
 }
Exemple #2
0
 public static function parse($url)
 {
     $oembed = null;
     foreach (self::$providers as $p) {
         if ($p->check($url)) {
             $oembed = $p->parse($url);
             break;
         }
     }
     if (empty($oembed)) {
         self::$defaultProvider = empty(self::$defaultProvider) ? new OEmbedDefaultProvider() : self::$defaultProvider;
         $oembed = self::$defaultProvider->parse($url);
     }
     if (!empty($oembed)) {
         $oembed['href'] = $url;
     }
     return $oembed;
 }
 /**
  * Return built HTML.
  *
  * @access	public
  * @return	mixed	String HTML to output or false on error.
  */
 public function getHtml()
 {
     if ($this->getVideoID() === false || $this->getWidth() === false || $this->getHeight() === false) {
         return false;
     }
     $html = false;
     if (array_key_exists('embed', $this->service)) {
         //Embed can be generated locally instead of calling out to the service to get it.
         $data = array($this->service['embed'], $this->getVideoID(), $this->getWidth(), $this->getHeight());
         if ($this->getExtraIds() !== false) {
             $data = array_merge($data, $this->getExtraIds());
         }
         $html = call_user_func_array('sprintf', $data);
     } elseif (array_key_exists('oembed', $this->service)) {
         //Call out to the service to get the embed HTML.
         if ($this->service['https_enabled']) {
             if (stristr($this->getVideoID(), 'https:') !== false) {
                 $protocol = 'https:';
             } else {
                 $protocol = 'http:';
             }
         }
         $url = sprintf($this->service['oembed'], $this->getVideoID(), $this->getWidth(), $this->getHeight(), $protocol);
         $oEmbed = OEmbed::newFromRequest($url);
         if ($oEmbed !== false) {
             $html = $oEmbed->getHtml();
         }
     }
     return $html;
 }
Exemple #4
0
/**
 * oEmbed field method: $page->video()->oembed()
 */
field::$methods['oembed'] = function ($field, $args = array()) {
    $oembed = new OEmbed($field->value);
    // autoplay setting
    if (isset($args['autoplay']) and $args['autoplay'] == true or c::get('oembed.autoplay', false)) {
        $oembed->autoplay = true;
    }
    // custom thumbnail
    if (isset($args['thumbnail'])) {
        $oembed->thumb->set($args['thumbnail']);
    }
    return $oembed->get($args);
};
/**
 * oEmbed Kirbytext tag: (oembed: https://youtube.com/watch?v=wZZ7oFKsKzY)
 */
kirbytext::$tags['oembed'] = array('attr' => array('class', 'thumb', 'autoplay', 'artwork', 'visual', 'size', 'color', 'jsapi'), 'html' => function ($tag) {
    $args = array('class' => $tag->attr('class', false), 'artwork' => $tag->attr('artwork', c::get('oembed.defaults.artwork', 'true')), 'visual' => $tag->attr('visual', c::get('oembed.defaults.visual', 'true')), 'size' => $tag->attr('size', c::get('oembed.defaults.size', 'default')), 'jsapi' => $tag->attr('jsapi', false));
    $oembed = new OEmbed($tag->attr('oembed'));
    // autoplay setting
    if ($tag->attr('autoplay', c::get('oembed.autoplay', false)) == 'true') {
        $oembed->autoplay = true;
    }
    // custom thumbnail
    if ($tag->attr('thumb', false)) {
        $oembed->thumb->set($tag->file($tag->attr('thumb'))->url());
    }
    return $oembed->get($args);
});
Exemple #5
0
<?php

// Include/require the class at the beginning
require_once "class_oembed.php";
// Create a class instance
$oembed = new OEmbed();
echo "<pre>";
echo "-----------------------------------------------------------------------------------<br />";
echo "------- OEmbed Test ---------------------------------------------------------------<br />";
echo "-----------------------------------------------------------------------------------<br />";
echo "<br />";
echo "<br />";
echo "<br />";
echo "<br />";
echo "-----------------------------------------------------------------------------------<br />";
echo "<br />";
echo "<br />";
echo "http://www.youtube.com/watch?v=EssrtKyCKVc<br /><br />";
// Use the method *getHtml()* to embed a object
echo $oembed->getHTML("http://www.youtube.com/watch?v=EssrtKyCKVc", array('width' => 300));
echo "<br /><br /><br />";
echo "-----------------------------------------------------------------------------------<br />";
echo "<br />";
echo "<br />";
echo "http://www.flickr.com/photos/scheiss_benji/4615831545/<br /><br />";
echo $oembed->getHTML("http://www.flickr.com/photos/scheiss_benji/4615831545/", array('width' => 300));
echo "<br /><br /><br />";
echo "-----------------------------------------------------------------------------------<br />";
echo "<br />";
echo "<br />";
echo "http://www.flickr.com/photos/nattu/3094752363/<br /><br />";
 /**
  * Return built HTML.
  *
  * @access	public
  * @return	mixed	String HTML to output or false on error.
  */
 public function getHtml()
 {
     if ($this->getVideoID() === false || $this->getWidth() === false || $this->getHeight() === false) {
         return false;
     }
     $html = false;
     if (isset($this->service['embed'])) {
         // Embed can be generated locally instead of calling out to the service to get it.
         $data = [$this->service['embed'], htmlentities($this->getVideoID(), ENT_QUOTES), $this->getWidth(), $this->getHeight()];
         if ($this->getExtraIds() !== false) {
             foreach ($this->getExtraIds() as $extraId) {
                 $data[] = htmlentities($extraId, ENT_QUOTES);
             }
         }
         $urlArgs = $this->getUrlArgs();
         if ($urlArgs !== false) {
             $data[] = $urlArgs;
         }
         $html = call_user_func_array('sprintf', $data);
     } elseif (isset($this->service['oembed'])) {
         // Call out to the service to get the embed HTML.
         if ($this->service['https_enabled']) {
             if (stristr($this->getVideoID(), 'https:') !== false) {
                 $protocol = 'https:';
             } else {
                 $protocol = 'http:';
             }
         }
         $url = sprintf($this->service['oembed'], $this->getVideoID(), $this->getWidth(), $this->getHeight(), $protocol);
         $oEmbed = OEmbed::newFromRequest($url);
         if ($oEmbed !== false) {
             $html = $oEmbed->getHtml();
         }
     }
     return $html;
 }
Exemple #7
0
 /**
  *
  * @param string $url
  * @return array
  */
 public static function getOEmbed($url)
 {
     return OEmbed::parse($url);
 }
Exemple #8
0
<?php

//http://youtu.be/Aqyf2aYR1pQ
OEmbed::addProvider(new OEmbedApiProvider('http://www.youtube.com/oembed?url=:url&format=json', array('~youtube\\.com/watch.+v=[\\w-]+&?~', '~youtu.be\\/[\\w-]+~')));
OEmbed::addProvider(new OEmbedApiProvider('http://www.flickr.com/services/oembed?url=:url&format=json', '~flickr\\.com/photos/[-.\\w@]+/\\d+/?~'));
OEmbed::addProvider(new OEmbedApiProvider('http://lab.viddler.com/services/oembed?url=:url&format=json', '~\\.viddler\\.com/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://qik.com/api/oembed.json?url=:url', '~qik\\.com/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://revision3.com/api/oembed?url=:url&format=json', '~\\.revision3\\.com/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://www.hulu.com/api/oembed.json?url=:url', '~hulu\\.com/watch/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://www.vimeo.com/api/oembed.json?url=:url', '~vimeo\\.com/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://www.polleverywhere.com/services/oembed?url=:url&format=json', array('~polleverywhere\\.com/polls/.+~', '~polleverywhere\\.com/multiple_choice_polls/.+~', '~polleverywhere\\.com/free_text_polls/.+~')));
OEmbed::addProvider(new OEmbedApiProvider('http://api.smugmug.com/services/oembed?url=:url&format=json', '~\\.smugmug\\.com/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://www.slideshare.net/api/oembed/2?url=:url&format=json', '~slideshare\\.net/.+/.+~'));
OEmbed::addProvider(new OEmbedApiProvider('http://public-api.wordpress.com/oembed?url=:url&format=json', array('~\\.wordpress\\.com/.+~', '~\\.wp\\.me/.+~')));