diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index fe146ee..e170991 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -179,8 +179,8 @@ public function rotate($degrees, $background = NULL) { /** * {@inheritdoc} */ - public function scaleAndCrop($width, $height, $upscale = TRUE) { - return $this->apply('scale_and_crop', array('width' => $width, 'height' => $height, 'upscale' => $upscale)); + public function scaleAndCrop($width, $height) { + return $this->apply('scale_and_crop', array('width' => $width, 'height' => $height)); } /** diff --git a/core/lib/Drupal/Core/Image/ImageInterface.php b/core/lib/Drupal/Core/Image/ImageInterface.php index 63ad482..02db478 100644 --- a/core/lib/Drupal/Core/Image/ImageInterface.php +++ b/core/lib/Drupal/Core/Image/ImageInterface.php @@ -142,14 +142,11 @@ public function scale($width, $height = NULL, $upscale = FALSE); * The target width, in pixels. * @param int $height * The target height, in pixels. - * @param bool $upscale - * (optional) Boolean indicating that files smaller than the dimensions will - * be scaled up. This generally results in a low quality image. * * @return bool * TRUE on success, FALSE on failure. */ - public function scaleAndCrop($width, $height, $upscale = TRUE); + public function scaleAndCrop($width, $height); /** * Crops an image to a rectangle specified by the given dimensions. diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml index fa50895..69fdd35 100644 --- a/core/modules/image/config/schema/image.schema.yml +++ b/core/modules/image/config/schema/image.schema.yml @@ -63,10 +63,6 @@ image.effect.image_scale: image.effect.image_scale_and_crop: type: image_size label: 'Image scale and crop' - mapping: - upscale: - type: boolean - label: 'Upscale' image.settings: type: mapping diff --git a/core/modules/image/image.module b/core/modules/image/image.module index ea95503..de32196 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -133,10 +133,6 @@ function image_theme() { 'variables' => array('data' => NULL, 'effect' => array()), 'template' => 'image-crop-summary', ), - 'image_scale_and_crop_summary' => array( - 'variables' => array('data' => NULL, 'effect' => array()), - 'template' => 'image-scale-and-crop-summary', - ), 'image_rotate_summary' => array( 'variables' => array('data' => NULL, 'effect' => array()), 'template' => 'image-rotate-summary', diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php index 607c7e3..ca9479f 100644 --- a/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php +++ b/core/modules/image/src/Plugin/ImageEffect/ScaleAndCropImageEffect.php @@ -24,74 +24,11 @@ class ScaleAndCropImageEffect extends ResizeImageEffect { * {@inheritdoc} */ public function applyEffect(ImageInterface $image) { - if (!$image->scaleAndCrop($this->configuration['width'], $this->configuration['height'], $this->configuration['upscale'])) { + if (!$image->scaleAndCrop($this->configuration['width'], $this->configuration['height'])) { $this->logger->error('Image scale and crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight())); return FALSE; } return TRUE; } - /** - * {@inheritdoc} - */ - public function transformDimensions(array &$dimensions) { - $width = $this->configuration['width']; - $height = $this->configuration['height']; - $image_width = $dimensions['width']; - $image_height = $dimensions['height']; - $upscale = $this->configuration['upscale']; - $scale = max($width / $image_width, $height / $image_height); - if (!$upscale && $scale >= 1) { - // When upscale is false and scale > 1, image will have original - // dimensions. - return TRUE; - } - // The new image will have the exact dimensions defined for the effect. - $dimensions['width'] = $this->configuration['width']; - $dimensions['height'] = $this->configuration['height']; - } - - /** - * {@inheritdoc} - */ - public function getSummary() { - $summary = array( - '#theme' => 'image_scale_and_crop_summary', - '#data' => $this->configuration, - ); - $summary += parent::getSummary(); - return $summary; - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return parent::defaultConfiguration() + array( - 'upscale' => TRUE, - ); - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, array &$form_state) { - $form = parent::buildConfigurationForm($form, $form_state); - $form['upscale'] = array( - '#type' => 'checkbox', - '#default_value' => $this->configuration['upscale'], - '#title' => t('Allow Upscaling'), - '#description' => t('Let scale make images larger than their original size'), - ); - return $form; - } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, array &$form_state) { - parent::submitConfigurationForm($form, $form_state); - $this->configuration['upscale'] = $form_state['values']['upscale']; - } - } diff --git a/core/modules/image/src/Tests/ImageAdminStylesTest.php b/core/modules/image/src/Tests/ImageAdminStylesTest.php index 7791de1..b84c87d 100644 --- a/core/modules/image/src/Tests/ImageAdminStylesTest.php +++ b/core/modules/image/src/Tests/ImageAdminStylesTest.php @@ -81,7 +81,6 @@ function testStyle() { 'image_scale_and_crop' => array( 'width' => 120, 'height' => 121, - 'upscale' => 1, ), 'image_crop' => array( 'width' => 130, diff --git a/core/modules/image/src/Tests/ImageEffectsTest.php b/core/modules/image/src/Tests/ImageEffectsTest.php index b9543d9..ad5c5d8 100644 --- a/core/modules/image/src/Tests/ImageEffectsTest.php +++ b/core/modules/image/src/Tests/ImageEffectsTest.php @@ -55,10 +55,10 @@ function testResizeEffect() { * Test the image_scale_effect() function. */ function testScaleEffect() { + // @todo: need to test upscaling. $this->assertImageEffect('image_scale', array( 'width' => 10, 'height' => 10, - 'upscale' => TRUE, )); $this->assertToolkitOperationsCalled(array('scale')); @@ -66,7 +66,6 @@ function testScaleEffect() { $calls = $this->imageTestGetAllCalls(); $this->assertEqual($calls['scale'][0][0], 10, 'Width was passed correctly'); $this->assertEqual($calls['scale'][0][1], 10, 'Height was based off aspect ratio and passed correctly'); - $this->assertTrue($calls['scale'][0][2], 'Upscale was passed correctly'); } /** @@ -96,7 +95,6 @@ function testScaleAndCropEffect() { $this->assertImageEffect('image_scale_and_crop', array( 'width' => 5, 'height' => 10, - 'upscale' => TRUE, )); $this->assertToolkitOperationsCalled(array('scale_and_crop')); @@ -104,7 +102,6 @@ function testScaleAndCropEffect() { $calls = $this->imageTestGetAllCalls(); $this->assertEqual($calls['scale_and_crop'][0][0], 5, 'Width was computed and passed correctly'); $this->assertEqual($calls['scale_and_crop'][0][1], 10, 'Height was computed and passed correctly'); - $this->assertTrue($calls['scale_and_crop'][0][2], 'Upscale was passed correctly'); } /** diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index d935ebd..d42f748 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -205,7 +205,7 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) { * * A module may deny all access to a node by setting $grants to an empty array. * - * @param array $grants + * @param $grants * The $grants array returned by hook_node_access_records(). * @param \Drupal\node\NodeInterface $node * The node for which the grants were acquired. @@ -360,7 +360,7 @@ function hook_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Se * * @param \Drupal\node\NodeInterface $node * The node being displayed in a search result. - * @param object $langcode + * @param $langcode * Language code of result being displayed. * * @return array @@ -387,7 +387,7 @@ function hook_node_search_result(\Drupal\node\NodeInterface $node, $langcode) { * * @param \Drupal\node\NodeInterface $node * The node being indexed. - * @param object $langcode + * @param $langcode * Language code of the variant of the node being indexed. * * @return string @@ -420,9 +420,9 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) { * * @param \Drupal\node\NodeInterface $node * The node being validated. - * @param array $form + * @param $form * The form being used to edit the node. - * @param \Drupal\Core\Form\FormStateInterface $form_state + * @param $form_state * The current state of the form. * * @ingroup entity_crud @@ -447,9 +447,9 @@ function hook_node_validate(\Drupal\node\NodeInterface $node, $form, \Drupal\Cor * * @param \Drupal\node\NodeInterface $node * The node entity being updated in response to a form submission. - * @param array $form + * @param $form * The form being used to edit the node. - * @param \Drupal\Core\Form\FormStateInterface $form_state + * @param $form_state * The current state of the form. * * @ingroup entity_crud