function imagepicker_image_page in Image Picker 7
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_image_page()
- 5 imagepicker.module \imagepicker_image_page()
- 6.2 imagepicker.functions.inc \imagepicker_image_page()
Menu callback; presents the image page for imagepicker
Parameters
numeric $img_id:
Return value
string
1 call to imagepicker_image_page()
File
- ./
imagepicker.functions.inc, line 256 - @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function imagepicker_image_page($img_id, $preset = FALSE) {
global $base_url;
$content = '';
$query = db_select('imagepicker', 'i');
$query
->fields('i', array(
'img_id',
'uid',
'img_name',
'img_title',
'img_description',
'img_date',
));
$query
->addField('u', 'name');
$query
->range(0, 1);
$query
->join('users', 'u', 'i.uid = u.uid');
$query
->condition('i.img_id', $img_id);
$img = $query
->execute()
->fetchObject();
// $img is now object
if ($img && is_object($img) && count($img)) {
drupal_add_css(IMAGEPICKER_PATH . '/imagepicker.css');
$title = isset($img->img_title) && $img->img_title ? htmlspecialchars_decode($img->img_title, ENT_QUOTES) : '';
if ($title) {
$title = $title . ' | ' . variable_get('site_name', 'Drupal');
drupal_set_title($title);
}
// js link
$account = user_load($img->uid);
$link = imagepicker_variable_get('imagepicker_default_pagelink', imagepicker_variable_get('imagepicker_default_pagelink', 1), $account->uid);
if (variable_get('file_default_scheme', 'public') == 'private') {
if (module_exists('image') && imagepicker_variable_get('imagepicker_image_enable', 0) && $preset) {
$imgpath = imagepicker_get_image_path($img, 'full', array(
'uid' => $img->uid,
), TRUE);
$imgpath = preg_replace("~__PRESET__~", $preset, $imgpath);
}
else {
$imgpath = imagepicker_get_image_path($img, 'full', array(
'uid' => $img->uid,
));
}
}
else {
if (module_exists('image') && imagepicker_variable_get('imagepicker_image_enable', 0) && $preset) {
$imgpath = imagepicker_get_image_path($img, 'full', array(
'uid' => $img->uid,
), TRUE);
$imgpath = preg_replace("~__PRESET__~", $preset, $imgpath);
}
else {
$imgpath = imagepicker_get_path(TRUE, $img) . $img->img_name;
}
}
$content = theme('imagepicker_fullpage', array(
'img' => $img,
'source' => $imgpath,
'link' => $link,
));
}
else {
drupal_set_message(t('Image not found in page.'), 'error');
}
return $content;
}