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
* {@inheritdoc}
*/
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);
/**
* Determines the dimensions of the styled image.
*
* @param array $dimensions
* Dimensions to be modified - an array with components width and height, in
* pixels.
* @param array &$dimensions
* Dimensions to be modified - an array with the following keys:
* - 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);
......
......@@ -23,12 +23,6 @@
*/
class ConvertImageEffect extends ConfigurableImageEffectBase {
/**
* {@inheritdoc}
*/
public function transformDimensions(array &$dimensions) {
}
/**
* {@inheritdoc}
*/
......
......@@ -21,12 +21,6 @@
*/
class DesaturateImageEffect extends ImageEffectBase {
/**
* {@inheritdoc}
*/
public function transformDimensions(array &$dimensions) {
}
/**
* {@inheritdoc}
*/
......
......@@ -221,8 +221,7 @@ function testImageDimensions() {
$effect_plugin = $style->getEffect($effect_id);
$style->deleteImageEffect($effect_plugin);
// Ensure that an effect with no dimensions callback unsets the dimensions.
// This ensures compatibility with 7.0 contrib modules.
// Ensure that an effect can unset dimensions.
$effect = array(
'id' => 'image_module_test_null',
'data' => array(),
......
......@@ -20,6 +20,14 @@
*/
class NullTestImageEffect extends ImageEffectBase {
/**
* {@inheritdoc}
*/
public function transformDimensions(array &$dimensions) {
// Unset image dimensions.
$dimensions['width'] = $dimensions['height'] = NULL;
}
/**
* {@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