Exemplo n.º 1
0
 public function setTextAttribute($text)
 {
     $text = str_replace(' ', ' ', $text);
     if ($this->slotname === 'standfirst') {
         $siteText = $text = strip_tags($text);
     } else {
         $embera = new Embera();
         $text = Str::makeInternalLinksRelative($text);
         $siteText = Str::StorifyEmbed($embera->autoEmbed($text));
     }
     $this->attributes['text'] = $text;
     $this->attributes['site_text'] = $siteText;
 }
Exemplo n.º 2
0
 /**
  * Replace embeddable URLs with the embed code.
  *
  * @param string $text
  *
  * @return string
  */
 public static function OEmbed($text)
 {
     $embera = new Embera();
     if ($data = $embera->getUrlInfo($text)) {
         $table = [];
         foreach ($data as $url => $service) {
             if (!empty($service['html'])) {
                 $table[$url] = $service['html'];
             }
         }
         foreach ($table as $url => $replacement) {
             $text = preg_replace('~(?<![\'\\"])' . preg_quote($url) . '(?![\'\\"])(?!\\</a\\>)~', $replacement, $text);
         }
     }
     return $text;
 }
Exemplo n.º 3
0
 /**
  * Retorna todas as informações da $url.
  * Para saber que tipo de informações são retornadas veja o link.
  * @link http://oembed.com
  * @param string $url A Url cujo queres informações.
  * @return null/array Retorna null se houver erro ao buscar informações sobre a $url. Ou um array com informações sobre a url.
  */
 public function fetchUrlInfo($url, $config = array())
 {
     if (!empty($config)) {
         $embera = new Embera($config);
     } else {
         $embera = new Embera();
     }
     // $embera = new \Embera\Formatter($embera);
     $urlInfo = $embera->getUrlInfo($url);
     $errors = $embera->getErrors();
     if (!empty($urlInfo) and empty($errors)) {
         $this->_urlInfo = $urlInfo;
         return $urlInfo;
     }
     return $errors;
 }
Exemplo n.º 4
0
 public function getVideoAttribute()
 {
     $embera = new Embera(array('params' => array('width' => 800, 'height' => 420)));
     return $embera->autoEmbed($this->video_url);
 }