You are here

function imagepicker_insert_image in Image Picker 6.2

Same name and namespace in other branches
  1. 7 imagepicker.functions.inc \imagepicker_insert_image()

Function to insert the image data into db

Parameters

$uid: Required user id

$img_name: Required image name

$img_title: Optional image title

$img_description: Optional image description

Return value

Returns the current img id

4 calls to imagepicker_insert_image()
imagepicker_copy_form_submit in ./imagepicker.functions.inc
Function to submit the copy form
imagepicker_import_batch in ./imagepicker.import.inc
imagepicker_postlet_do in contribs/imagepicker_postlet/imagepicker_postlet.module
Function to process the postlet applet callbacks
imagepicker_upload_form_submit in ./imagepicker.upload.inc
Submit form

File

./imagepicker.functions.inc, line 2802
Imagepicker functions

Code

function imagepicker_insert_image($uid, $img_name, $img_title = "", $img_description = "") {
  if (!$uid || !$img_name) {
    return FALSE;
  }
  if (drupal_strlen($img_description) > 254) {
    $img_description = drupal_substr($img_description, 0, 254);
  }
  $date = time();
  $result = db_query("INSERT INTO {imagepicker} (uid, img_name, img_title, img_description, img_date) VALUES ('%d', '%s', '%s', '%s', '%s')", array(
    $uid,
    $img_name,
    check_plain($img_title),
    check_plain($img_description),
    $date,
  ));
  if ($result) {
    $nextimgid = db_last_insert_id("imagepicker", 'img_id');
    return $nextimgid;
  }
  return FALSE;
}