You are here

function bynder_file_delete in Bynder 7

Implements hook_file_delete().

File

./bynder.module, line 317

Code

function bynder_file_delete($file) {
  if ($file->type == 'image' && $file->filemime == 'image/bynder') {
    try {
      db_delete('bynder_media_entity')
        ->condition('fid', $file->fid)
        ->execute();
      bynder_delete_asset_usage_information($file->fid);
      drupal_set_message(t('Bynder Media assets linked to the deleted files were also removed from the associated pages.'), 'status', FALSE);
    } catch (Exception $e) {
      drupal_set_message(t('An error ocurred when deleting the Bynder information for file with id @file_id.', [
        '@file_id' => $file->fid,
      ]), 'error');
      watchdog('bynder', $e
        ->getMessage());
    }
  }
}