Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Issue #2319159 by mondrake | alexpott: Fixed Crop anchor selector doe…
Browse files Browse the repository at this point in the history
…s not work.
  • Loading branch information
alexpott committed Sep 8, 2014
1 parent f48f760 commit 27b28ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
9 changes: 9 additions & 0 deletions core/modules/image/src/Plugin/ImageEffect/CropImageEffect.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,13 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
return $form;
}

/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);

$this->configuration['anchor'] = $form_state->getValue('anchor');
}

}
41 changes: 23 additions & 18 deletions core/modules/image/src/Tests/ImageAdminStylesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Drupal\image\Tests;

use Drupal\Component\Utility\String;
use Drupal\image\ImageStyleInterface;

/**
Expand Down Expand Up @@ -69,30 +70,30 @@ function testStyle() {
$style_path = $admin_path . '/manage/' . $style_name;
$effect_edits = array(
'image_resize' => array(
'data[width]' => 100,
'data[height]' => 101,
'width' => 100,
'height' => 101,
),
'image_scale' => array(
'data[width]' => 110,
'data[height]' => 111,
'data[upscale]' => 1,
'width' => 110,
'height' => 111,
'upscale' => 1,
),
'image_scale_and_crop' => array(
'data[width]' => 120,
'data[height]' => 121,
'width' => 120,
'height' => 121,
),
'image_crop' => array(
'data[width]' => 130,
'data[height]' => 131,
'data[anchor]' => 'center-center',
'width' => 130,
'height' => 131,
'anchor' => 'left-top',
),
'image_desaturate' => array(
// No options for desaturate.
),
'image_rotate' => array(
'data[degrees]' => 5,
'data[random]' => 1,
'data[bgcolor]' => '#FFFF00',
'degrees' => 5,
'random' => 1,
'bgcolor' => '#FFFF00',
),
);

Expand All @@ -115,10 +116,14 @@ function testStyle() {

// Add each sample effect to the style.
foreach ($effect_edits as $effect => $edit) {
$edit_data = array();
foreach ($edit as $field => $value) {
$edit_data['data[' . $field . ']'] = $value;
}
// Add the effect.
$this->drupalPostForm($style_path, array('new' => $effect), t('Add'));
if (!empty($edit)) {
$this->drupalPostForm(NULL, $edit, t('Add effect'));
$this->drupalPostForm(NULL, $edit_data, t('Add effect'));
}
}

Expand All @@ -128,15 +133,15 @@ function testStyle() {
$style_uri_path = $style->url();
$this->assertTrue(strpos($style_uri_path, $style_path) !== FALSE, 'The image style URI is correct.');

// Confirm that all effects on the image style have settings on the effect
// edit form that match what was saved.
// Confirm that all effects on the image style have settings that match
// what was saved.
$uuids = array();
foreach ($style->getEffects() as $uuid => $effect) {
// Store the uuid for later use.
$uuids[$effect->getPluginId()] = $uuid;
$this->drupalGet($style_path . '/effects/' . $uuid);
$effect_configuration = $effect->getConfiguration();
foreach ($effect_edits[$effect->getPluginId()] as $field => $value) {
$this->assertFieldByName($field, $value, format_string('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value)));
$this->assertEqual($value, $effect_configuration['data'][$field], String::format('The %field field in the %effect effect has the correct value of %value.', array('%field' => $field, '%effect' => $effect->getPluginId(), '%value' => $value)));
}
}

Expand Down

0 comments on commit 27b28ea

Please sign in to comment.