コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $element['show_preview'] = array('#type' => 'checkbox', '#title' => t('Show cropping preview'), '#default_value' => $this->getSetting('show_preview'));
     $element['collapsible'] = array('#type' => 'radios', '#title' => t('Collapsible behavior'), '#options' => array(1 => t('None.'), 2 => t('Collapsible, expanded by default.'), 3 => t('Collapsible, collapsed by default.')), '#default_value' => $this->getSetting('collapsible'));
     // Resolution settings.
     $resolution = $this->getSetting('resolution');
     list($res_w, $res_h) = explode('x', $resolution);
     $element['resolution'] = array('#title' => t('The resolution to crop the image onto'), '#element_validate' => array(array('Drupal\\image\\Plugin\\Field\\FieldType\\ImageItem', 'validateResolution'), array(get_class($this), 'validateResolution')), '#theme_wrappers' => array('form_element'), '#description' => t('The output resolution of the cropped image, expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 not to rescale after cropping. Note: output resolution must be defined in order to present a dynamic preview.'));
     $element['resolution']['x'] = array('#type' => 'textfield', '#default_value' => isset($res_w) ? $res_w : '', '#size' => 5, '#maxlength' => 5, '#field_suffix' => ' x ', '#theme_wrappers' => array());
     $element['resolution']['y'] = array('#type' => 'textfield', '#default_value' => isset($res_h) ? $res_h : '', '#size' => 5, '#maxlength' => 5, '#field_suffix' => ' ' . t('pixels'), '#theme_wrappers' => array());
     $element['enforce_ratio'] = array('#type' => 'checkbox', '#title' => t('Enforce crop box ratio'), '#default_value' => $this->getSetting('enforce_ratio'), '#description' => t('Check this to force the ratio of the output on the crop box. NOTE: If you leave this unchecked but enforce an output resolution, the final image might be distorted'), '#element_validate' => array(array(get_class($this), 'validateEnforceRatio')));
     $element['enforce_minimum'] = array('#type' => 'checkbox', '#title' => t('Enforce minimum crop size based on the output size'), '#default_value' => $this->getSetting('enforce_minimum'), '#description' => t('Check this to force a minimum cropping selection equal to the output size. NOTE: If you leave this unchecked you might get zoomed pixels if the cropping area is smaller than the output resolution.'), '#element_validate' => array(array(get_class($this), 'validateEnforceMinimum')));
     // Crop area settings
     $croparea = $this->getSetting('croparea');
     list($crop_w, $crop_h) = explode('x', $croparea);
     $element['croparea'] = array('#title' => t('The resolution of the cropping area'), '#element_validate' => array(array(get_class($this), 'validateCropArea')), '#theme_wrappers' => array('form_element'), '#description' => t('The resolution of the area used for the cropping of the image. Image will displayed at this resolution for cropping. Use WIDTHxHEIGHT format, empty or zero values are permitted, e.g. 500x will limit crop box to 500 pixels width.'));
     $element['croparea']['x'] = array('#type' => 'textfield', '#default_value' => isset($crop_w) ? $crop_w : '', '#size' => 5, '#maxlength' => 5, '#field_suffix' => ' x ', '#theme_wrappers' => array());
     $element['croparea']['y'] = array('#type' => 'textfield', '#default_value' => isset($crop_h) ? $crop_h : '', '#size' => 5, '#maxlength' => 5, '#field_suffix' => ' ' . t('pixels'), '#theme_wrappers' => array());
     return $element;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $element['crop_preview_image_style'] = array('#title' => t('Crop preview image style'), '#type' => 'select', '#options' => image_style_options(FALSE), '#empty_option' => '<' . t('no preview') . '>', '#default_value' => $this->getSetting('preview_image_style'), '#description' => t('The preview image will be shown while editing the content.'), '#weight' => 15);
     $element['crop_list'] = ['#title' => t('Image style cropped'), '#type' => 'select', '#options' => image_style_options(FALSE), '#empty_option' => '<' . t('no preview') . '>', '#default_value' => $this->getSetting('crop_list'), '#multiple' => TRUE, '#description' => t('The preview image will be cropped.'), '#weight' => 16];
     return $element;
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $element['preview_image_style'] = array('#title' => t('Grid image style'), '#type' => 'select', '#options' => image_style_options(FALSE), '#required' => TRUE, '#default_value' => $this->getSetting('preview_image_style'), '#description' => t('The preview image will be shown while editing the content. Recommended use preview image style with dimension more than 220x220.'), '#weight' => 15);
     return $element;
 }