How do I get the file URI from an EntityMetadataWrapper object? Getting hold of file objects related to nodes through a field is easy using an EntityMetadataWrapper:

$wrapper = entity_metadata_wrapper('node', $node);
$images = $wrapper-&gt;field_images;


So that's great. However, I want to use some of the properties of the standard file object, and they're not available. When I look at the properties available on $images[0]-&gt;file using the above code, I see these:


fid
name
mime
size
url
timestamp
owner


Most notably, uri is missing, and in its place there's a url property, which is the full external URL to the image file. I want to manipulate these images via their URI (create thumbs, etc), so I'm left doing this:

$fid = $images[0]-&gt;file-&gt;fid-&gt;value();
$uri = file_load($fid)-&gt;uri;


Which seems to negate the whole point of using an EntityMetadataWrapper in the first place.

What am I missing? Where is the URI on the wrapped file object? If it's not available, for the love of all things good and pure, why not?!

I'm aware I could deconstruct the URL back to a URI, but that also feels very unnecessary.
Big thanks to MPD for pointing me in the right direction. In short, without the File Entity module, files aren't entities, so they don't naturally have the 'properties' I was expecting.

The Entity module provides some on their behalf, but URI isn't one of them. Fortunately it's very simple to make it available using hook_entity_property_info_alter() and a custom property callback:

function MYMODULE_entity_property_info_alter(&amp;$info) {
  $info['file']['properties']['uri'] = array(
    'label' =&gt; t("URI"),
    'description' =&gt; t("The URI of the file."),
    'getter callback' =&gt; 'MYMODULE_entity_get_file_properties',
    'schema field' =&gt; 'uri',
  );
}

function MYMODULE_entity_get_file_properties($file, array $options, $name) {
  switch ($name) {
    case 'uri':
      return $file-&gt;uri;
      break;
  }
}


After that, $images[0]-&gt;file-&gt;uri-&gt;value() is available as expected.