diff --git a/includes/media.filter.inc b/includes/media.filter.inc index 4be5e1a..8953cba 100644 --- a/includes/media.filter.inc +++ b/includes/media.filter.inc @@ -847,3 +847,21 @@ function _media_token_uuid_replace($matches, $entity_uuid_function) { } return '[[' . drupal_json_encode($tag_info) . ']]'; } + +/** + * Implements hook_entity_update(). + * + * Purge cached fields for entities which contain an embedded version of the + * updated entity. + */ +function media_entity_update($entity, $type) { + if ($type == 'file') { + $list = file_usage_list($entity); + foreach ($list['media'] as $entity_type => $references) { + foreach (array_keys($references) as $id) { + $cid = "field:$entity_type:$id"; + cache_clear_all($cid, 'cache_field'); + } + } + } +}