You are here

function imagepicker_image_page in Image Picker 5

Same name and namespace in other branches
  1. 5.2 imagepicker.module \imagepicker_image_page()
  2. 6.2 imagepicker.functions.inc \imagepicker_image_page()
  3. 7 imagepicker.functions.inc \imagepicker_image_page()

Menu callback; presents the image page for imagepicker

1 string reference to 'imagepicker_image_page'
imagepicker_menu in ./imagepicker.module
Implementation of hook_menu().

File

./imagepicker.module, line 684
Enables permitted roles to upload images for insertion into configured nodes.

Code

function imagepicker_image_page() {
  global $base_url;
  $content = '';
  $result = db_query_range("SELECT i.*, u.name FROM {imagepicker} AS i JOIN {users} AS u USING (uid) WHERE img_id = '%d'", arg(2), 0, 1);
  $img = db_fetch_array($result);
  if (!is_array($img) || !count($img)) {
    drupal_set_message(t('Image not found.'), 'error');
    $content = '';
  }
  else {
    $path = drupal_get_path('module', 'imagepicker');
    drupal_add_css($path . '/imagepicker.css');
    drupal_set_title(check_plain($img['img_title']));
    $imgsrc = imagepicker_get_path(TRUE, $img) . $img['img_name'];
    $content = '<div id="imgp_page"><div id="imgp_page_img">';
    $content .= '<a href="' . $imgsrc . '" alt="' . check_plain($img['img_title']) . '" target="_blank">';
    $content .= '<img src="' . $imgsrc . '" alt="' . $img['img_title'] . '" />';
    $content .= '</a></div><div>' . nl2br($img['img_description']) . '</div>';
    if (variable_get('imagepicker_default_pagelink', 1)) {
      $content .= '<div><a href="#" onclick="history.back()">' . t('Return to page') . '</a></div>';
    }
    $content .= '</div>';
  }
  return $content;
}