Skip to content

Commit 9616d4e

Browse files
committed
Merge branch 'release/1.4.25' into v1
2 parents a5816d8 + 2466b8e commit 9616d4e

File tree

9 files changed

+32
-13
lines changed

9 files changed

+32
-13
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# ImageOptimize Changelog
22

3+
## 1.4.25 - 2018.03.30
4+
### Changed
5+
* Fixed a typo in the `config.php` settings, changed `generatePlacholders` -> `generatePlaceholders`
6+
* Made the reduced quality of retina images if `lowerQualityRetinaImageVariants` is enabled less aggressive
7+
38
## 1.4.24 - 2018.03.19
49
### Changed
510
* Fixed an issue with propagating field data in multi-site environments

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nystudio107/craft-imageoptimize",
33
"description": "Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like Imgix, with zero template changes.",
44
"type": "craft-plugin",
5-
"version": "1.4.24",
5+
"version": "1.4.25",
66
"keywords": [
77
"craft",
88
"cms",

src/ImageOptimize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ImageOptimize extends Plugin
8484
/**
8585
* @var bool
8686
*/
87-
public static $generatePlacholders = true;
87+
public static $generatePlaceholders = true;
8888

8989
// Public Methods
9090
// =========================================================================

src/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
'generateTransformsBeforePageLoad' => true,
4848

4949
// Set to false to disable all placeholder generation
50-
'generatePlacholders' => true,
50+
'generatePlaceholders' => true,
5151

5252
// Controls whether a dominant color palette should be created for image variants
5353
// It takes a bit of time, so if you never plan to use it, you can turn it off

src/fields/OptimizedImages.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ class OptimizedImages extends Field
9090
public function __construct(array $config = [])
9191
{
9292
// Unset any deprecated properties
93-
unset($config['transformMethod']);
94-
unset($config['imgixDomain']);
93+
if (!empty($config)) {
94+
unset($config['transformMethod']);
95+
unset($config['imgixDomain']);
96+
}
9597
parent::__construct($config);
9698
}
9799

src/models/Settings.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Settings extends Model
6666
/**
6767
* @var bool Set to false to disable all placeholder generation
6868
*/
69-
public $generatePlacholders = true;
69+
public $generatePlaceholders = true;
7070

7171
/**
7272
* @var bool Controls whether a dominant color palette should be created
@@ -256,6 +256,18 @@ class Settings extends Model
256256
// Public Methods
257257
// =========================================================================
258258

259+
/**
260+
* @inheritdoc
261+
*/
262+
public function __construct(array $config = [])
263+
{
264+
// Unset any deprecated properties
265+
if (!empty($config)) {
266+
unset($config['generatePlacholders']);
267+
}
268+
parent::__construct($config);
269+
}
270+
259271
/**
260272
* @inheritdoc
261273
*/

src/services/Optimize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function handleGenerateTransformEvent(GenerateTransformEvent $event)
106106

107107
$settings = ImageOptimize::$plugin->getSettings();
108108
// Only do this for local Craft transforms
109-
if ($settings->transformMethod == 'craft' && !empty($event->asset) && ImageOptimize::$generatePlacholders) {
109+
if ($settings->transformMethod == 'craft' && !empty($event->asset) && ImageOptimize::$generatePlaceholders) {
110110
// Apply any filters to the image
111111
if (!empty($event->transformIndex->transform)) {
112112
$this->applyFiltersToImage($event->transformIndex->transform, $event->asset, $event->image);

src/services/OptimizedImages.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function populateOptimizedImageModel(Asset $asset, $variants, OptimizedIm
150150
protected function generatePlaceholders(Asset $element, OptimizedImage $model, $aspectRatio)
151151
{
152152
$settings = ImageOptimize::$plugin->getSettings();
153-
if ($settings->generatePlacholders && ImageOptimize::$generatePlacholders) {
153+
if ($settings->generatePlaceholders && ImageOptimize::$generatePlaceholdersholders) {
154154
$placeholder = ImageOptimize::$plugin->placeholder;
155155
if ($element->focalPoint) {
156156
$position = $element->getFocalPoint();
@@ -199,7 +199,7 @@ protected function getTransformFromVariant(Asset $asset, $variant, $retinaSize):
199199
// Image quality
200200
$quality = $variant['quality'];
201201
if ($settings->lowerQualityRetinaImageVariants && $retinaSize != '1') {
202-
$quality = intval($quality * (1 / intval($retinaSize)));
202+
$quality = intval($quality * (1.5 / intval($retinaSize)));
203203
}
204204
$transform->quality = $quality;
205205
// Interlaced (progressive JPEGs or interlaced PNGs)
@@ -284,7 +284,7 @@ public function updateOptimizedImageFieldData(Field $field, ElementInterface $as
284284
->update($table, [
285285
$column => $data,
286286
], [
287-
'elementId' => $asset->getId(),
287+
'id' => $asset->contentId,
288288
], [], false)
289289
->execute();
290290
}

src/variables/ImageOptimizeVariable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ public function placeholderBox($width, $height, $color = null)
4444
/**
4545
* @param Asset $asset
4646
* @param array $variants
47-
* @param bool $generatePlacholders
47+
* @param bool $generatePlaceholders
4848
*
4949
* @return OptimizedImage|null
5050
*/
5151
public function createOptimizedImages(
5252
Asset $asset,
5353
$variants = null,
54-
$generatePlacholders = false
54+
$generatePlaceholders = false
5555
) {
5656
// Override our settings for lengthy operations, since we're doing this via Twig
57-
ImageOptimize::$generatePlacholders = $generatePlacholders;
57+
ImageOptimize::$generatePlaceholders = $generatePlaceholders;
5858

5959
return ImageOptimize::$plugin->optimizedImages->createOptimizedImages($asset, $variants);
6060
}

0 commit comments

Comments
 (0)