You are here

function filehash_rss_elements in File Hash 7

Same name and namespace in other branches
  1. 8 filehash.module \filehash_rss_elements()

Adds <media:hash> RSS elements to $node object.

1 call to filehash_rss_elements()
filehash_node_view in ./filehash.module
Implements hook_node_view().

File

./filehash.module, line 166
Generate hashes for each uploaded file.

Code

function filehash_rss_elements(array $file, $node) {
  $names = array(
    'md5' => 'md5',
    'sha1' => 'sha-1',
  );
  foreach ($names as $algo => $name) {
    if (!empty($file['filehash'][$algo])) {
      $node->rss_elements[] = array(
        'key' => 'media:hash',
        'attributes' => array(
          'algo' => $name,
        ),
        'value' => $file['filehash'][$algo],
      );
    }
  }
  $node->rss_namespaces['xmlns:media'] = 'http://search.yahoo.com/mrss/';
}