You are here

private function SoEmbedFilter::getContents in Simple oEmbed 8

Locally create HTML after pattern study for sites that don't support oEmbed.

1 call to SoEmbedFilter::getContents()
SoEmbedFilter::embed in src/Plugin/Filter/SoEmbedFilter.php
Callback function to process each URL

File

src/Plugin/Filter/SoEmbedFilter.php, line 128

Class

SoEmbedFilter
Plugin annotation @Filter( id = "filter_soembed", title = @Translation("Simple oEmbed filter"), description = @Translation("Embeds media for URL that supports oEmbed standard."), settings = { "soembed_maxwidth" = 500, …

Namespace

Drupal\soembed\Plugin\Filter

Code

private function getContents($provider, $url) {
  $width = $this->settings['soembed_maxwidth'];
  switch ($provider) {
    case 'google-maps':

      //$url    = str_replace('&', '&', $url); Though Google encodes ampersand, it seems to work without it.
      $height = (int) ($width / 1.3);
      $embed = "<iframe width='{$width}' height='{$height}' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='{$url}&output=embed'></iframe><br /><small><a href='{$url}&source=embed' style='color:#0000FF;text-align:left'>View Larger Map</a></small>";
      break;
    case 'google-docs':
      $height = (int) ($width * 1.5);
      $embed = "<iframe width='{$width}' height='{$height}' frameborder='0' src='{$url}&widget=true'></iframe>";
      break;
    default:
      $embed = $url;
  }
  return $embed;
}