You are here

function imagefield_menu in ImageField 5.2

Same name and namespace in other branches
  1. 5 imagefield.module \imagefield_menu()

Implementation of hook_menu().

File

./imagefield.module, line 14
Defines an image field type. imagefield uses content.module to store the fid, and the drupal files table to store the actual file data.

Code

function imagefield_menu($maycache) {
  $items = array();
  if ($maycache) {
    $items[] = array(
      'path' => 'imagefield/js',
      'callback' => 'imagefield_js',
      //'access' => user_access(),
      'access' => true,
      'type' => MENU_CALLBACK,
    );
  }
  elseif ($_SESSION['imagefield']) {

    // Iterate over each field stored in session imagefield looking
    // for files in a preview state to add menu items for. This
    // allows us to preview new uploads before a node is submitted.
    foreach ($_SESSION['imagefield'] as $fieldname => $files) {

      // move on to the next field if there is nothing to process in files.
      if (empty($files)) {
        continue;
      }
      foreach ($files as $delta => $file) {

        // If the file is not a preview do not display it.
        if (empty($file['preview'])) {
          continue;
        }
        $items[] = array(
          'path' => $file['preview'],
          'callback' => '_imagefield_preview',
          'callback arguments' => array(
            $file['preview'],
          ),
          'access' => true,
          'type' => MENU_CALLBACK,
        );
      }
    }
  }
  return $items;
}