You are here

function mediafront_plugin_style_player_advanced::getFieldRawUrl in MediaFront 7

Returns a full URL to a media or file field. Accepts media fields and raw text fields.

1 call to mediafront_plugin_style_player_advanced::getFieldRawUrl()
mediafront_plugin_style_player_advanced::render in views/mediafront_plugin_style_player_advanced.inc
Renders the media player.

File

views/mediafront_plugin_style_player_advanced.inc, line 120
This file holds style plugin for MediaFront Views

Class

mediafront_plugin_style_player_advanced
@class Extension of the Views Plugin Syle for the Media Player from MediaFront

Code

function getFieldRawUrl($row_id, $field_name) {
  $media_url = '';
  if (isset($this->display->handler->handlers['field'][$field_name]->field_info['type'])) {
    $field_type = $this->display->handler->handlers['field'][$field_name]->field_info['type'];
    switch ($field_type) {
      case 'file':
      case 'image':
      case 'media':
        if (isset($this->view->result[$row_id]->{"field_{$field_name}"}[0])) {
          if ($field_type == 'media') {
            $uri = $this->view->result[$row_id]->{"field_{$field_name}"}[0]['raw']['file']->uri;
          }
          else {
            $uri = $this->view->result[$row_id]->{"field_{$field_name}"}[0]['raw']['uri'];
          }
          $stream_wrapper = file_stream_wrapper_get_instance_by_uri($uri);
          if (is_object($stream_wrapper)) {
            $media_url = $stream_wrapper
              ->getExternalUrl();
          }
        }
        break;
      default:
        break;
    }
  }
  if (!$media_url) {
    $media_url = $this->view
      ->render_field($field_name, $row_id);
  }
  return $media_url;
}