First I tried to understand how entities work and how they can be extracted and manipulated using Entity Metadata Wrappers. That seems to work ok, for example, I can get the values of my imagefield like this:
$nid = 103025; $node_wrapper = entity_metadata_wrapper('node', $nid); $images = $node_wrapper->field_image->value();
And it seems that I could change the values of the images with something like this:
// Do something with $images $node_wrapper->field_image->set($images); $node_wrapper->revision->set(1); $node_wrapper->save();
(For some reason it's not saving the values for the node in my case, but that's another question.)
My problem now is that I have nested fields, i.e. the imagefield has "subfields" for the source and license (that I had added in Drupal 6 using Imagefield Extended). I do get the values of those nested fields in $images - but only in the typical array with
$images[und]['safe_value']. But there seems to be no way to get those values through the wrapper, for example like
Now I have been trying for hours to figure out how I can change (or populate) those (sub) fields and then save the entire node, but to no avail.
I'm also wondering if it's necessary to do this on a node level as files are also entities, but it seems that there is nothing like
I'd appreciate any hint that could point me in the right direction because the search has been kind of exhausting.