Embera\Embera::autoEmbed PHP Méthode

autoEmbed() public méthode

Embeds known/available services into the given text.
public autoEmbed ( string $body = null ) : string
$body string
Résultat string
    public function autoEmbed($body = null)
    {
        if (!is_string($body)) {
            $this->errors[] = 'For auto-embedding purposes, the input must be a string';
        } elseif ($data = $this->getUrlInfo($body)) {
            $table = array();
            foreach ($data as $url => $service) {
                if (!empty($service['html'])) {
                    $table[$url] = $service['html'];
                }
            }
            // Determine wether the body looks like HTML or just plain text.
            if (strpos($body, '>') !== false) {
                $processor = new \Embera\HtmlProcessor($this->config['ignore_tags'], $table);
                return $processor->process($body);
            }
            return strtr($body, $table);
        }
        return $body;
    }

Usage Example

Exemple #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;
 }
All Usage Examples Of Embera\Embera::autoEmbed