File field URI to URL link in module I'm creating a custom file field display formatter module..
https://www.drupal.org/sandbox/vincer/2779871

Right now it's just printing the URI as..

public://my-file.mid


I'm trying to get the default output that I would get by using the File module - a full path as a link, like..

http://my-site/sites/default/files/my-file.mid


The field_formatter_view looks like..

function fieldmidity_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $settings = $display['settings'];
  $element = array();  

  if ($display['type'] == 'midi_formatter') {
    foreach ($items as $delta =&gt; $item) {
      $element[$delta] = array('#markup' =&gt; $item['uri']);
      // Options for $item; filename, uri, description, filesize, timestamp, fid, uid
    }
  }

  return $element;
}


Based on code I see in the File and Field modules, I'm suspecting that the solution might be more complicated than the approach that I'm attempting.

Any thoughts would be appreciated.
Use this:

function fieldmidity_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $settings = $display['settings'];
  $element = array();  

  if ($display['type'] == 'midi_formatter') {
    foreach ($items as $delta =&gt; $item) {
        if ($item['uri']){
            $element[$delta] = array('#markup' =&gt; file_create_url($item['uri']));
        }else{ 
            $element[$delta] = array('#markup' =&gt; $item['uri']);
        }
      // Options for $item; filename, uri, description, filesize, timestamp, fid, uid
    }
  }

  return $element;
}