You are here

function _epsacrop_process_form_element in EPSA Crop - Image Cropping 8.2

Helper function that add a link in image widget field to open a dialog for the crops.

@access private

Return value

void

1 string reference to '_epsacrop_process_form_element'
epsacrop_element_info_alter in ./epsacrop.module
Implements hook_element_info_alter.

File

./epsacrop.module, line 435
The main file of module

Code

function _epsacrop_process_form_element($element, $form_state) {
  if (user_access('epsacrop create crops') || user_access('epsacrop edit all crops')) {
    if (isset($element['#field_name'])) {
      _epsacrop_include_header_html();
      $styles = _epsacrop_load_styles_by_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
      if (!empty($styles) && (isset($element['#file']) && is_object($element['#file']))) {
        $file = $element['#file'];
        $url = image_style_url('epsacrop_thumb', $file->uri);
        $info = image_get_info($file->uri);
        $element['epsacrop'] = array(
          '#type' => 'markup',
          '#markup' => "[<a href=\"javascript:Drupal.EPSACrop.dialog('" . $element['#entity_type'] . "', '" . $element['#field_name'] . "', '" . $element['#bundle'] . "', '" . $file->fid . "', '" . $url . "', [" . $info['width'] . "," . $info['height'] . "]);\">" . t("manage image crops") . "</a>]",
        );
      }
    }
  }
  return $element;
}