Skip to content

Instantly share code, notes, and snippets.

@szeidler
Created October 19, 2017 12:01
Show Gist options
  • Save szeidler/43a0d18df215752b4289860b999989df to your computer and use it in GitHub Desktop.
Save szeidler/43a0d18df215752b4289860b999989df to your computer and use it in GitHub Desktop.
Writeback metadata using the FotowebSteamWrapper
if ($file_wrapper = file_stream_wrapper_get_instance_by_uri($file->uri)) {
// Specifiy the Fotoweb property to update.
$metadata_key_to_update = 60;
// Set the new value.
$file->metadata['asset_metadata'][$metadata_key_to_update]['value'] = 'My new caption';
// Update the metadata and trigger the file_save, which could
// overwrite the $file->metadata with the actual asset metadata
// for data consistency.
if ($file_wrapper->update_metadata(array($metadata_key_to_update => $file->metadata['asset_metadata'][$metadata_key_to_update]))) {
file_save($file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment