You are here

public function Image::scale in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Image/Image.php \Drupal\Core\Image\Image::scale()

Scales an image while maintaining aspect ratio.

The resulting image can be smaller for one or both target dimensions.

Parameters

int|null $width: The target width, in pixels. If this value is null then the scaling will be based only on the height value.

int|null $height: (optional) The target height, in pixels. If this value is null then the scaling will be based only on the width value.

bool $upscale: (optional) Boolean indicating that files smaller than the dimensions will be scaled up. This generally results in a low quality image.

Return value

bool TRUE on success, FALSE on failure.

Overrides ImageInterface::scale

File

core/lib/Drupal/Core/Image/Image.php, line 203
Contains \Drupal\Core\Image\Image.

Class

Image
Defines an image object to represent an image file.

Namespace

Drupal\Core\Image

Code

public function scale($width, $height = NULL, $upscale = FALSE) {
  return $this
    ->apply('scale', array(
    'width' => $width,
    'height' => $height,
    'upscale' => $upscale,
  ));
}