function slider_validate_picture in Featured Content Slider 7.2
Same name in this branch
- 7.2 contrib/eb_custom_slider.module \slider_validate_picture()
- 7.2 contrib/custom_slider/eb_custom_slider.module \slider_validate_picture()
2 string references to 'slider_validate_picture'
- eb_custom_slider_form in contrib/
eb_custom_slider.module - implementation of hook_form().
- eb_custom_slider_form in contrib/
custom_slider/ eb_custom_slider.module - implementation of hook_form().
File
- contrib/
custom_slider/ eb_custom_slider.module, line 204 - display content in 'featured content' block using jquery.
Code
function slider_validate_picture(&$form, &$form_state) {
global $nid;
//print_r($form_state);
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array(
'400x300',
),
'file_validate_size' => array(
30 * 1024,
),
);
if ($file = file_save_upload('picture_upload', $validators)) {
// remove the old picture.
if (isset($form_state['values']['_product']->image_path) && file_exists($form_state['values']['_product']->image_path)) {
file_delete($form_state['values']['_product']->image_path);
}
$productid = 0;
if (!isset($form_state['values']['productid'])) {
// execute in case of new product
$query = "show table status like 'slider'";
$rs = db_query($query);
$row = db_fetch_object($rs);
$productid = isset($row->auto_increment) ? $row->auto_increment : 0;
}
else {
$productid = $form_state['values']['productid'];
}
$info = image_get_info($file->filepath);
$destination = variable_get('image_default_path', 'images/temp') . '/picture-' . time() . '.' . $info['extension'];
//$query = db_query("insert INTO slider(slider_title, image_path, nid) values('%s', '%s' , '%d')",$form_state['values']['title'],$destination,$nid);
if (file_copy($file, $destination, file_exists_replace)) {
$form_state['values']['picture'] = $file->filepath;
}
else {
form_set_error('picture_upload', t("failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array(
'%directory' => variable_get('product_picture_path', 'product_pictures'),
)));
}
}
}