You are here

function filehash_rss_elements in File Hash 8

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

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

1 call to filehash_rss_elements()
filehash_node_build_defaults_alter in ./filehash.module
Implements hook_ENTITY_TYPE_build_defaults_alter().

File

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

Code

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