diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 2b384bb..98f9a89 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -5,6 +5,7 @@ * Administration pages for image settings. */ +use Drupal\Component\Utility\String; use Drupal\image\ImageStyleInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -74,7 +75,7 @@ function image_style_form($form, &$form_state, ImageStyleInterface $style) { $key = $effect->getUuid(); $form['effects'][$key]['#weight'] = isset($form_state['input']['effects']) ? $form_state['input']['effects'][$key]['weight'] : NULL; $form['effects'][$key]['label'] = array( - '#markup' => check_plain($effect->label()), + '#markup' => String::checkPlain($effect->label()), ); $form['effects'][$key]['summary'] = $effect->getSummary(); $form['effects'][$key]['weight'] = array( diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectAddForm.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectAddForm.php index 012ed4a..106cb08 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectAddForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectAddForm.php @@ -70,7 +70,10 @@ public function buildForm(array $form, array &$form_state, Request $request = NU * {@inheritdoc} */ protected function prepareImageEffect($image_effect) { - return $this->effectManager->createInstance($image_effect); + $image_effect = $this->effectManager->createInstance($image_effect); + // Set the initial weight so this effect comes last. + $image_effect->setWeight(count($this->imageStyle->getEffects())); + return $image_effect; } } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectEditForm.php index dd810c0..671c065 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectEditForm.php @@ -34,11 +34,6 @@ public function buildForm(array $form, array &$form_state, Request $request = NU drupal_set_title(t('Edit %label effect', array('%label' => $this->imageEffect->label())), PASS_THROUGH); $form['actions']['submit']['#value'] = t('Update effect'); - // If the weight is not specified in the URL, use the default. - if ($this->imageEffect->getWeight() !== '' && !$request->query->has('weight')) { - $form['weight']['#value'] = $this->imageEffect->getWeight(); - } - return $form; } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php index bfe7f5b..c472f58 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php @@ -10,8 +10,8 @@ use Drupal\Core\Form\FormInterface; use Drupal\image\ImageStyleInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Provides a base form for image effects. @@ -49,15 +49,17 @@ public function getFormID() { * @param string $image_effect * The image effect ID. * - * @return array|\Symfony\Component\HttpFoundation\RedirectResponse + * @return array * The form structure. + * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function buildForm(array $form, array &$form_state, Request $request = NULL, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $this->imageStyle = $image_style; $this->imageEffect = $this->prepareImageEffect($image_effect); if (!$this->imageEffect->hasForm()) { - return new RedirectResponse(url('admin/config/media/image-styles/manage/' . $image_style->id(), array('absolute' => TRUE))); + throw new NotFoundHttpException(); } $form['#attached']['css'][drupal_get_path('module', 'image') . '/css/image.admin.css'] = array(); @@ -76,7 +78,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU // Check the URL for a weight, then the image effect, otherwise use default. $form['weight'] = array( '#type' => 'hidden', - '#value' => $request->query->has('weight') ? intval($request->query->get('weight')) : count($this->imageStyle->getEffects()), + '#value' => $request->query->has('weight') ? intval($request->query->get('weight')) : $this->imageEffect->getWeight(), ); $form['actions'] = array('#type' => 'actions'); diff --git a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php index 391564a..ae06d37 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php +++ b/core/modules/image/lib/Drupal/image/Plugin/ImageEffect/CropImageEffect.php @@ -64,15 +64,15 @@ public function getForm() { '#type' => 'radios', '#title' => t('Anchor'), '#options' => array( - 'left-top' => t('Top') . ' ' . t('Left'), - 'center-top' => t('Top') . ' ' . t('Center'), - 'right-top' => t('Top') . ' ' . t('Right'), - 'left-center' => t('Center') . ' ' . t('Left'), + 'left-top' => t('Top') . ' ' . t('Left'), + 'center-top' => t('Top') . ' ' . t('Center'), + 'right-top' => t('Top') . ' ' . t('Right'), + 'left-center' => t('Center') . ' ' . t('Left'), 'center-center' => t('Center'), - 'right-center' => t('Center') . ' ' . t('Right'), - 'left-bottom' => t('Bottom') . ' ' . t('Left'), + 'right-center' => t('Center') . ' ' . t('Right'), + 'left-bottom' => t('Bottom') . ' ' . t('Left'), 'center-bottom' => t('Bottom') . ' ' . t('Center'), - 'right-bottom' => t('Bottom') . ' ' . t('Right'), + 'right-bottom' => t('Bottom') . ' ' . t('Right'), ), '#theme' => 'image_anchor', '#default_value' => $this->configuration['anchor'],