You are here

function editor_entity_field_count_files in Editor 7

Retrieve a count of all of the files referenced by an entity.

Parameters

string $entity_type: The type of the entity whose files are being counted.

object $entity: The entity whose files are being counted.

Return value

array An array of file counts keyed by file ID.

2 calls to editor_entity_field_count_files()
editor_field_attach_delete_revision in includes/editor.file_usage.inc
Implements hook_field_attach_delete_revision().
_editor_filter_add_file_usage_from_fields in includes/editor.file_usage.inc
Add file usage from file references in an entity's text fields.

File

includes/editor.file_usage.inc, line 124
Tracks usage of embedded files.

Code

function editor_entity_field_count_files($entity_type, $entity) {
  $file_count = array();

  // Loop through the entity's file references and create a total count for each
  // file.
  foreach (editor_filter_parse_from_fields($entity_type, $entity) as $fid) {
    if (empty($file_count[$fid])) {
      $file_count[$fid] = 1;
    }
    else {
      $file_count[$fid]++;
    }
  }
  return $file_count;
}