Skip to content

Commit 3755531

Browse files
committed
Merge branch 'release/1.4.30' into v1
2 parents 20bd58c + 09cf32b commit 3755531

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

CHANGELOG.md

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

3+
## 1.4.30 - 2018.04.09
4+
### Added
5+
* Added additional profiling information
6+
37
## 1.4.29 - 2018.04.06
48
### Added
59
* Added profiling to the image variant creation

composer.json

Lines changed: 2 additions & 2 deletions
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.29",
5+
"version": "1.4.30",
66
"keywords": [
77
"craft",
88
"cms",
@@ -28,7 +28,7 @@
2828
"minimum-stability": "dev",
2929
"prefer-stable": true,
3030
"require": {
31-
"craftcms/cms": "^3.0.0-RC12",
31+
"craftcms/cms": "^3.0.0",
3232
"imgix/imgix-php": "^1.1.0",
3333
"ksubileau/color-thief-php": "^1.3",
3434
"mikehaertl/php-shellcommand": "~1.2"

src/services/Optimize.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Optimize extends Component
5353
*/
5454
public function handleGetAssetUrlEvent(GetAssetUrlEvent $event)
5555
{
56+
Craft::beginProfile('handleGetAssetUrlEvent', __METHOD__);
5657
$url = null;
5758
$settings = ImageOptimize::$plugin->getSettings();
5859
if ($settings->transformMethod != 'craft') {
@@ -89,6 +90,7 @@ public function handleGetAssetUrlEvent(GetAssetUrlEvent $event)
8990
ImageOptimize::$transformParams
9091
);
9192
}
93+
Craft::endProfile('handleGetAssetUrlEvent', __METHOD__);
9294

9395
return $url;
9496
}
@@ -102,6 +104,7 @@ public function handleGetAssetUrlEvent(GetAssetUrlEvent $event)
102104
*/
103105
public function handleGenerateTransformEvent(GenerateTransformEvent $event)
104106
{
107+
Craft::beginProfile('handleGenerateTransformEvent', __METHOD__);
105108
$tempPath = null;
106109

107110
$settings = ImageOptimize::$plugin->getSettings();
@@ -152,6 +155,7 @@ public function handleGenerateTransformEvent(GenerateTransformEvent $event)
152155
$tempPath
153156
);
154157
}
158+
Craft::endProfile('handleGenerateTransformEvent', __METHOD__);
155159

156160
return $tempPath;
157161
}
@@ -200,6 +204,7 @@ public function saveTransformToTempFile(AssetTransformIndex $index, Image $image
200204
*/
201205
public function optimizeImage(AssetTransformIndex $index, string $tempPath)
202206
{
207+
Craft::beginProfile('optimizeImage', __METHOD__);
203208
$settings = ImageOptimize::$plugin->getSettings();
204209
// Get the active processors for the transform format
205210
$activeImageProcessors = $settings->activeImageProcessors;
@@ -215,6 +220,7 @@ public function optimizeImage(AssetTransformIndex $index, string $tempPath)
215220
}
216221
}
217222
}
223+
Craft::endProfile('optimizeImage', __METHOD__);
218224
}
219225

220226
/**
@@ -244,6 +250,7 @@ public function humanFileSize($bytes, $decimals = 1): string
244250
*/
245251
public function createImageVariants(AssetTransformIndex $index, Asset $asset, string $tempPath)
246252
{
253+
Craft::beginProfile('createImageVariants', __METHOD__);
247254
$settings = ImageOptimize::$plugin->getSettings();
248255
// Get the active image variant creators
249256
$activeImageVariantCreators = $settings->activeImageVariantCreators;
@@ -304,6 +311,7 @@ public function createImageVariants(AssetTransformIndex $index, Asset $asset, st
304311
}
305312
}
306313
}
314+
Craft::endProfile('createImageVariants', __METHOD__);
307315
}
308316

309317
/**

src/services/OptimizedImages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function populateOptimizedImageModel(Asset $asset, $variants, OptimizedIm
153153
*/
154154
protected function generatePlaceholders(Asset $element, OptimizedImage $model, $aspectRatio)
155155
{
156+
Craft::beginProfile('generatePlaceholders', __METHOD__);
156157
$settings = ImageOptimize::$plugin->getSettings();
157158
if ($settings->generatePlaceholders && ImageOptimize::$generatePlaceholders) {
158159
$placeholder = ImageOptimize::$plugin->placeholder;
@@ -177,6 +178,7 @@ protected function generatePlaceholders(Asset $element, OptimizedImage $model, $
177178
@unlink($tempPath);
178179
}
179180
}
181+
Craft::endProfile('generatePlaceholders', __METHOD__);
180182
}
181183

182184
/**

src/services/Placeholder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function generatePlaceholderBox($width, $height, $color = null)
8080
*/
8181
public function generatePlaceholderImage(string $tempPath, float $aspectRatio, $position): string
8282
{
83+
Craft::beginProfile('generatePlaceholderImage', __METHOD__);
8384
$result = '';
8485
$width = self::PLACEHOLDER_WIDTH;
8586
$height = intval($width / $aspectRatio);
@@ -88,6 +89,7 @@ public function generatePlaceholderImage(string $tempPath, float $aspectRatio, $
8889
$result = base64_encode(file_get_contents($placeholderPath));
8990
unlink($placeholderPath);
9091
}
92+
Craft::endProfile('generatePlaceholderImage', __METHOD__);
9193

9294
return $result;
9395
}
@@ -101,6 +103,7 @@ public function generatePlaceholderImage(string $tempPath, float $aspectRatio, $
101103
*/
102104
public function generateColorPalette(string $tempPath): array
103105
{
106+
Craft::beginProfile('generateColorPalette', __METHOD__);
104107
$colorPalette = [];
105108
if (!empty($tempPath)) {
106109
// Extract the color palette
@@ -110,6 +113,7 @@ public function generateColorPalette(string $tempPath): array
110113
$colorPalette[] = sprintf("#%02x%02x%02x", $colors[0], $colors[1], $colors[2]);
111114
}
112115
}
116+
Craft::endProfile('generateColorPalette', __METHOD__);
113117

114118
return $colorPalette;
115119
}
@@ -123,6 +127,7 @@ public function generateColorPalette(string $tempPath): array
123127
*/
124128
public function generatePlaceholderSvg(string $tempPath): string
125129
{
130+
Craft::beginProfile('generatePlaceholderSvg', __METHOD__);
126131
$result = '';
127132

128133
if (!empty($tempPath)) {
@@ -151,7 +156,7 @@ public function generatePlaceholderSvg(string $tempPath): string
151156
}
152157
}
153158
}
154-
159+
Craft::endProfile('generatePlaceholderSvg', __METHOD__);
155160

156161
return $result;
157162
}
@@ -168,9 +173,11 @@ public function generatePlaceholderSvg(string $tempPath): string
168173
*/
169174
public function createTempPlaceholderImage(Asset $asset, float $aspectRatio, $position): string
170175
{
176+
Craft::beginProfile('createTempPlaceholderImage', __METHOD__);
171177
$width = self::TEMP_PLACEHOLDER_WIDTH;
172178
$height = intval($width / $aspectRatio);
173179
$tempPath = $this->createImageFromAsset($asset, $width, $height, self::TEMP_PLACEHOLDER_QUALITY, $position);
180+
Craft::endProfile('createTempPlaceholderImage', __METHOD__);
174181

175182
return $tempPath;
176183
}

0 commit comments

Comments
 (0)