Skip to content

Commit 34d9482

Browse files
committed
Merge branch 'release/1.6.12' into v1
2 parents 528e743 + ac03e94 commit 34d9482

File tree

5 files changed

+37
-1
lines changed

5 files changed

+37
-1
lines changed

CHANGELOG.md

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

3+
## 1.6.12 - 2020.03.21
4+
### Added
5+
* Added the `createAsset` console command for regenerating the responsive image variants for a single Asset ID
6+
7+
### Changed
8+
* Generated image URLs that have no file format extension are now properly displayed in the GUI (an issue mostly with serverless Sharp)
9+
310
## 1.6.11 - 2020.02.12
411
### Changed
512
* Sanity check the inputs before normalizaing the file format

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.6.11",
5+
"version": "1.6.12",
66
"keywords": [
77
"craft",
88
"cms",

docs/docs/Using.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ If you want to generate only responsive image variants for a specific Asset Volu
7272
./craft image-optimize/optimize/create blogImages
7373
```
7474

75+
If you want to generate only responsive image variants for a specific Asset, you can do that by specifying the Asset ID via the console command `createAsset`:
76+
77+
```
78+
./craft image-optimize/optimize/createAsset 101
79+
```
80+
7581
Craft CMS also comes with several [built-in Console Commands](https://nystudio107.com/blog/exploring-the-craft-cms-3-console-command-line-interface-cli) that are useful for Image Transforms:
7682

7783
```

src/console/controllers/OptimizeController.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,24 @@ public function actionCreate($volumeHandle = null)
6262
App::maxPowerCaptain();
6363
Craft::$app->getQueue()->run();
6464
}
65+
66+
/**
67+
* Create a single OptimizedImage for the passed in Asset ID
68+
*
69+
* @param int|null $id
70+
*/
71+
public function actionCreateAsset($id = null)
72+
{
73+
echo 'Creating optimized image variants'.PHP_EOL;
74+
75+
if ($id === null) {
76+
echo 'No Asset ID specified'.PHP_EOL;
77+
} else {
78+
// Re-save a single Asset ID
79+
ImageOptimize::$plugin->optimizedImages->resaveAsset($id);
80+
}
81+
// This might take a while
82+
App::maxPowerCaptain();
83+
Craft::$app->getQueue()->run();
84+
}
6585
}

src/templates/_components/fields/OptimizedImages_input.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@
134134
</div>
135135
{% set thisFormat = thisUrl | split('.') | last %}
136136
{% set thisFormat = thisFormat | split('?') | first %}
137+
{% if thisFormat | length > 4 %}
138+
{% set thisFormat = variant.format %}
139+
{% endif %}
137140
{% if imageSource == value.optimizedWebPImageUrls %}
138141
{% set thisFormat = ".webp" %}
139142
{% endif %}

0 commit comments

Comments
 (0)