Example #1
0
 /**
  *	Fetches embed information from the given URL.
  *
  *	@param string $url URL to fetch informations from.
  *	@param array $options Custom options to be interpreted by the provider.
  *	@return Media|null Embed informations, or null if nothing could be
  *		fetched.
  */
 public final function embed($url, array $options = [])
 {
     $Media = null;
     if (is_callable($this->prepare)) {
         $url = call_user_func($this->prepare, $url, $options);
     }
     try {
         $Media = $this->_embed($url, $options);
         $Media->setDefault('url', $url);
         if ($this->_Preparator) {
             $this->_Preparator->complete($Media, $options);
         }
     } catch (Exception $Exception) {
         $this->_Logger->log(Logger::notice, "Unable to embed {$url}", ['exception' => $Exception]);
     }
     return $Media;
 }
Example #2
0
 /**
  *	{@inheritDoc}
  */
 public function complete(Media $Media, array $options = [])
 {
     parent::complete($Media, $options);
     if ($Media->get('type') === 'vine-app:video' && preg_match('#https?://vine.co/v/[a-zA-Z0-9]+#i', $Media->get('url'), $matches)) {
         $Media->set('html:small', '<iframe class="vine-embed" src="' . $matches[0] . '/embed/postcard" width="320" height="320" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>');
         $Media->set('html:medium', '<iframe class="vine-embed" src="' . $matches[0] . '/embed/postcard" width="480" height="480" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>');
         $Media->set('html:large', '<iframe class="vine-embed" src="' . $matches[0] . '/embed/postcard" width="600" height="600" frameborder="0"></iframe><script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>');
         $Media->set('html', $Media->get('html:small'));
     }
 }
Example #3
0
 /**
  *	{@inheritDoc}
  */
 public function complete(Media $Media, array $options = [])
 {
     parent::complete($Media, $options);
     if ($Media->has('og:video') && $Media->get('og:video:type') === 'application/x-shockwave-flash' && preg_match('/((album|track)=\\d+)/', $Media->get('og:video'), $matches)) {
         $url = htmlspecialchars($Media->get('url'));
         $title = htmlspecialchars($Media->get('title'));
         $height = $matches[2] == 'album' ? 470 : 442;
         $Media->set('html:small', '<iframe style="border: 0; width: 100%; height: 42px;" src="http://bandcamp.com/EmbeddedPlayer/' . $matches[1] . '/size=small/bgcol=ffffff/linkcol=0687f5/transparent=true/" seamless><a href="' . htmlspecialchars($Media->get('url')) . '">' . $title . '</a></iframe>');
         $Media->set('html:medium', '<iframe style="border: 0; width: 100%; height: 120px;" sr="http://bandcamp.com/EmbeddedPlayer/' . $matches[1] . '/size=large/bgcol=ffffff/linkcol=0687f5/tracklist=false/artwork=small/transparent=true/" seamless><a href="' . $url . '">' . $title . '</a></iframe>');
         $Media->set('html:large', '<iframe style="border: 0; width: 350px; height: ' . $height . 'px;" src="http://bandcamp.com/EmbeddedPlayer/' . $matches[1] . '/size=large/bgcol=ffffff/linkcol=0687f5/tracklist=false/transparent=true/" seamless><a href="' . $url . '">' . $title . '</a></iframe>');
         $Media->set('html', $Media->get('html:small'));
     }
 }
Example #4
0
 /**
  *	{@inheritDoc}
  *
  *	@param array $options Embed options.
  *		- 'thumbnailFormat' string
  */
 public function complete(Media $Media, array $options = [])
 {
     parent::complete($Media, $options);
     if (isset($options['thumbnailFormat'])) {
         $url = $Media->get('thumbnailUrl');
         switch ($options['thumbnailFormat']) {
             case 'small':
                 $url = str_replace('hqdefault', 'default', $url);
                 break;
             case 'medium':
                 $url = str_replace('hqdefault', 'mqdefault', $url);
                 break;
             case 'large':
             default:
                 // unchanged
                 break;
         }
         $Media->set('thumbnailUrl', $url);
     }
 }