mirror of
https://github.com/getgrav/grav.git
synced 2026-02-23 07:01:26 +01:00
Fix orientation when auto_fix_orientation option is enabled
Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
@@ -266,11 +266,6 @@ class Excerpts
|
||||
);
|
||||
}
|
||||
|
||||
$config = $this->getConfig();
|
||||
if (!empty($config['images']['auto_fix_orientation'])) {
|
||||
$actions[] = ['method' => 'fixOrientation', 'params' => ''];
|
||||
}
|
||||
|
||||
$defaults = $config['images']['defaults'] ?? [];
|
||||
if (count($defaults)) {
|
||||
foreach ($defaults as $method => $params) {
|
||||
|
||||
@@ -24,6 +24,8 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
use ImageMediaTrait;
|
||||
use ImageLoadingTrait;
|
||||
|
||||
protected static $orientationFixed;
|
||||
|
||||
/**
|
||||
* Construct.
|
||||
*
|
||||
@@ -89,6 +91,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
$this->medium_querystring = [];
|
||||
$this->filter();
|
||||
$this->clearAlternatives();
|
||||
static::$orientationFixed = null;
|
||||
}
|
||||
|
||||
$this->format = 'guess';
|
||||
@@ -276,6 +279,16 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate
|
||||
$this->image();
|
||||
}
|
||||
|
||||
// Fix orientation if enabled
|
||||
if (!isset(static::$orientationFixed)) {
|
||||
if (Grav::instance()['config']->get('system.images.auto_fix_orientation', false)) {
|
||||
$this->image->fixOrientation();
|
||||
static::$orientationFixed = true;
|
||||
} else {
|
||||
static::$orientationFixed = false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->image->{$method}(...$args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user