Commit 7c05a8b5 authored by webchick's avatar webchick

Issue #2420751 by Wim Leers, mondrake, attiks:...

Issue #2420751 by Wim Leers, mondrake, attiks: ImageEffectBase::transformDimensions() should have a sane default implementation
parent 8c0f9342
...@@ -71,7 +71,9 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -71,7 +71,9 @@ public static function create(ContainerInterface $container, array $configuratio
* {@inheritdoc} * {@inheritdoc}
*/ */
public function transformDimensions(array &$dimensions) { public function transformDimensions(array &$dimensions) {
$dimensions['width'] = $dimensions['height'] = NULL; // Most image effects will not change the dimensions. This base
// implementation represents this behavior. Override this method if your
// image effect does change the dimensions.
} }
/** /**
......
...@@ -37,9 +37,12 @@ public function applyEffect(ImageInterface $image); ...@@ -37,9 +37,12 @@ public function applyEffect(ImageInterface $image);
/** /**
* Determines the dimensions of the styled image. * Determines the dimensions of the styled image.
* *
* @param array $dimensions * @param array &$dimensions
* Dimensions to be modified - an array with components width and height, in * Dimensions to be modified - an array with the following keys:
* pixels. * - width: the width in pixels, or NULL if unknown
* - height: the height in pixels, or NULL if unknown
* When either of the dimensions are NULL, the corresponding HTML attribute
* will be omitted when an image style using this image effect is used.
*/ */
public function transformDimensions(array &$dimensions); public function transformDimensions(array &$dimensions);
......
...@@ -23,12 +23,6 @@ ...@@ -23,12 +23,6 @@
*/ */
class ConvertImageEffect extends ConfigurableImageEffectBase { class ConvertImageEffect extends ConfigurableImageEffectBase {
/**
* {@inheritdoc}
*/
public function transformDimensions(array &$dimensions) {
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -21,12 +21,6 @@ ...@@ -21,12 +21,6 @@
*/ */
class DesaturateImageEffect extends ImageEffectBase { class DesaturateImageEffect extends ImageEffectBase {
/**
* {@inheritdoc}
*/
public function transformDimensions(array &$dimensions) {
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -221,8 +221,7 @@ function testImageDimensions() { ...@@ -221,8 +221,7 @@ function testImageDimensions() {
$effect_plugin = $style->getEffect($effect_id); $effect_plugin = $style->getEffect($effect_id);
$style->deleteImageEffect($effect_plugin); $style->deleteImageEffect($effect_plugin);
// Ensure that an effect with no dimensions callback unsets the dimensions. // Ensure that an effect can unset dimensions.
// This ensures compatibility with 7.0 contrib modules.
$effect = array( $effect = array(
'id' => 'image_module_test_null', 'id' => 'image_module_test_null',
'data' => array(), 'data' => array(),
......
...@@ -20,6 +20,14 @@ ...@@ -20,6 +20,14 @@
*/ */
class NullTestImageEffect extends ImageEffectBase { class NullTestImageEffect extends ImageEffectBase {
/**
* {@inheritdoc}
*/
public function transformDimensions(array &$dimensions) {
// Unset image dimensions.
$dimensions['width'] = $dimensions['height'] = NULL;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment