Getting hold of file objects related to nodes through a field is easy using an EntityMetadataWrapper
:
$wrapper = entity_metadata_wrapper('node', $node);
$images = $wrapper->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]->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]->file->fid->value();
$uri = file_load($fid)->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.
hook_entity_property_info_alter()
" then that's fine, just wanted to knowentity_metadata_system_entity_property_info()
, where a bunch of new properties get tacked onto$info['file']['properties']
. I'm willing to bet if file_entity was in there that array would already have the entity properties themselves in there. I'll try to write an answer up later or tomorrow if no-one's already done ituri
is there with file_entity.