You are here

private static function Heartbeat::mediaTag in Heartbeat 8

1 call to Heartbeat::mediaTag()
Heartbeat::buildMediaMarkup in src/Entity/Heartbeat.php

File

src/Entity/Heartbeat.php, line 540

Class

Heartbeat

Namespace

Drupal\heartbeat\Entity

Code

private static function mediaTag($type, $filePath) {
  if ($type == 'image') {
    $type = 'img';
    return '<' . $type . ' src="' . str_replace('public://', '/sites/default/files/', $filePath) . '" class="heartbeat-image" / >';
  }
  else {
    if ($type == 'youtube') {
      $filePath = str_replace('youtube://', 'https://www.youtube.com/embed/', $filePath);
      return '<iframe class="heartbeat-youtube" width="auto" height="auto" src="' . $filePath . '" frameborder="0"></iframe>';
    }
    else {
      if ($type == 'video') {
        return '<' . $type . ' controls src="' . str_replace('public://', '/sites/default/files/', $filePath) . '" class="heartbeat-video"></' . $type . '>';
      }
    }
  }
}