You are here

public function ShortcodeBase::getMediaFileUrl in Shortcode 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/ShortcodeBase.php \Drupal\shortcode\Plugin\ShortcodeBase::getMediaFileUrl()

Get the file url for a media object.

Parameters

int $mid: Media id.

Return value

mixed|int|bool The media id if found.

1 call to ShortcodeBase::getMediaFileUrl()
ShortcodeBase::getUrlFromPath in src/Plugin/ShortcodeBase.php
Returns a url to be used in a link element given path or url.

File

src/Plugin/ShortcodeBase.php, line 281

Class

ShortcodeBase
Provides a base class for Shortcode plugins.

Namespace

Drupal\shortcode\Plugin

Code

public function getMediaFileUrl($mid) {
  $media_entity = Media::load($mid);
  $field_media = $this
    ->getMediaField($media_entity);
  if ($field_media) {
    $file = $field_media->entity;
    return file_create_url($file
      ->getFileUri());
  }
  return FALSE;
}