function imageoffsets_form in Image javascript crop 6
Callback to return offsets, height & width
Parameters
$file current file being cropped:
$preset Preset beïng cropped:
$fid id of file:
$module specific module:
Return value
array $form
1 string reference to 'imageoffsets_form'
- imagecrop_docrop in ./
imagecrop.admin.inc - Callback with javascript crop.
File
- ./
imagecrop.admin.inc, line 238 - Administration functions for Imagecrop
Code
function imageoffsets_form(&$form_state, $file, $preset, $fid, $module, $field, $node_type) {
$step = variable_get('imagecrop_scale_step', 50);
$aspect = $file->orig_width / $file->orig_height;
$options = array();
if ($step > 0) {
$original_width = $file->orig_width;
$options['original'] = $file->orig_width . ' x ' . $file->orig_height . 'px (Original)';
$file->orig_width -= $step;
while ($file->orig_width > $file->crop_width && $file->orig_width / $aspect > $file->crop_height) {
$options[$file->orig_width] = $file->orig_width . ' x ' . intval($file->orig_width / $aspect) . 'px (' . round($file->orig_width / $original_width * 100, 2) . '%)';
$file->orig_width -= $step;
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Crop image thumbnail'),
'#prefix' => '<table id="imagecrop_table_actions"><tr><td>',
'#suffix' => '</td>',
);
// only show when there are multiple scaling options available
if (count($options) > 1) {
$form['scaling'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => $file->scale,
'#prefix' => '<td id="imagecrop-throbber">',
'#suffix' => '</td></tr></table>',
'#attributes' => array(
'onchange' => "\$('#imagecrop-throbber').addClass('show'); \$('#edit-scaledown').click();",
),
);
$form['scaledown'] = array(
'#type' => 'submit',
'#value' => t('Scale image'),
'#attributes' => array(
'style' => "display:none;",
),
);
}
$form['image-crop-x'] = array(
'#type' => 'hidden',
'#default_value' => $file->xoffset,
'#attributes' => array(
'class' => 'edit-image-crop-x',
),
);
$form['image-crop-y'] = array(
'#type' => 'hidden',
'#default_value' => $file->yoffset,
'#attributes' => array(
'class' => 'edit-image-crop-y',
),
);
$form['image-crop-width'] = array(
'#type' => 'hidden',
'#default_value' => $file->crop_width,
'#attributes' => array(
'class' => 'edit-image-crop-width',
),
);
$form['image-crop-height'] = array(
'#type' => 'hidden',
'#default_value' => $file->crop_height,
'#attributes' => array(
'class' => 'edit-image-crop-height',
),
);
$form['fid'] = array(
'#type' => 'hidden',
'#value' => $fid,
);
$form['module'] = array(
'#type' => 'hidden',
'#value' => $module,
);
$form['field'] = array(
'#type' => 'hidden',
'#value' => $field,
);
$form['node_type'] = array(
'#type' => 'hidden',
'#value' => $node_type,
);
$form['presetname'] = array(
'#type' => 'hidden',
'#value' => $preset,
);
$form['preset-destination'] = array(
'#type' => 'hidden',
'#value' => $file->preset_destination,
);
$form['temp-preset-destination'] = array(
'#type' => 'hidden',
'#value' => $file->dst,
);
return $form;
}