Same filename in this branch
- 10 core/lib/Drupal/Component/Utility/Image.php
- 10 core/lib/Drupal/Core/Image/Image.php
- 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Image.php
- 10 core/modules/media/src/Plugin/media/Source/Image.php
Same filename and directory in other branches
- 8.9.x core/lib/Drupal/Component/Utility/Image.php
- 9 core/lib/Drupal/Component/Utility/Image.php
Namespace
Drupal\Component\Utility
File
core/lib/Drupal/Component/Utility/Image.php
View source
<?php
namespace Drupal\Component\Utility;
class Image {
public static function scaleDimensions(array &$dimensions, $width = NULL, $height = NULL, $upscale = FALSE) {
$aspect = $dimensions['height'] / $dimensions['width'];
if ($width && !$height || $width && $height && $aspect < $height / $width) {
$height = (int) round($width * $aspect);
}
else {
$width = (int) round($height / $aspect);
}
if (!$upscale && ($width >= $dimensions['width'] || $height >= $dimensions['height'])) {
return FALSE;
}
$dimensions['width'] = $width;
$dimensions['height'] = $height;
return TRUE;
}
}
Classes
Name |
Description |
Image |
Provides helpers to operate on images. |