You are here

function bynder_create_media_entry in Bynder 7

2 calls to bynder_create_media_entry()
bynder_save_image in includes/bynder.browser.inc
sync_old_bynder_media in includes/bynder.utils.inc

File

includes/bynder.browser.inc, line 171
Manages the Bynder media browser functionality

Code

function bynder_create_media_entry($selected_media, $idHash, $fid) {

  // Save Bynder asset entry.
  $name = $selected_media['name'];
  $description = isset($selected_media['description']) ? $selected_media['description'] : '';
  $derivatives = $selected_media['thumbnails'];
  $schema = drupal_get_schema('bynder_media_entity');
  if (isset($schema['fields']['description']['length'])) {
    $maxlength = $schema['fields']['description']['length'];
  }
  $description = isset($maxlength) ? substr($description, 0, $maxlength) : $description;
  $bynder_media_entity_id = db_insert('bynder_media_entity')
    ->fields(array(
    'bynder_id' => $selected_media['id'],
    'bynder_hash_id' => $idHash,
    'name' => $name,
    'description' => $description,
    'derivatives' => serialize($derivatives),
    'fid' => $fid,
  ))
    ->execute();
  bynder_create_media_usage_entry($selected_media, $fid, $bynder_media_entity_id);
}