You are here

function scald_dnd_library_scald_render in Scald: Media Management made easy 7

Same name and namespace in other branches
  1. 6 scald_dnd_library/scald_dnd_library.module \scald_dnd_library_scald_render()

Implements hook_scald_render().

File

modules/library/scald_dnd_library/scald_dnd_library.module, line 168
Scald DnD Library

Code

function scald_dnd_library_scald_render($atom, $context, $options) {
  if (!empty($atom->rendered->thumbnail_transcoded_url)) {
    $path = $atom->rendered->thumbnail_transcoded_url;
  }
  else {
    $path = image_style_url('library', $atom->thumbnail_source);
  }
  $attributes = array();
  if ($context == 'sdl_library_item') {
    $attributes += array(
      'class' => 'drop',
      'draggable' => 'TRUE',
      'data-atom-id' => $atom->sid,
    );
  }
  elseif ($context == 'sdl_preview') {
    $attributes += array(
      'class' => 'drop',
      'draggable' => 'TRUE',
      'data-atom-id' => $atom->sid,
    );
  }
  else {
    $attributes += array(
      'class' => 'dnd-dropped',
    );
  }
  $image = "<img src='{$path}' alt='' " . drupal_attributes($attributes) . ' />';
  switch ($context) {
    case 'sdl_preview':
      $render = theme('sdl_preview_item', array(
        'atom' => $atom,
        'image' => $image,
      ));
      break;
    case 'sdl_library_item':
      $render = theme('sdl_library_item', array(
        'atom' => $atom,
        'image' => $image,
      ));
      break;
    default:
      $render = array(
        '#theme' => 'sdl_editor_item',
        '#informations' => $atom->rendered,
        '#image' => $image,
      );
  }
  return $render;
}