Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
Fixed a major bug causing the queue to build up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roel van Hintum committed Nov 5, 2018
1 parent 46c6c0a commit c7e8509
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.0-beta.4 - 2018-11-05
### Fixed
- Fixed a major bug causing the queue to build up.

## 2.0.0-beta.3 - 2018-10-08
### Fixed
- Fixed errors thrown when imageColor field is missing on assets.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "born05/craft-colorextractor",
"description": "Extract colors from image assets in Craft CMS. Requires a field named `imageColor` on all assets of kind image (can be color or plaintext)",
"type": "craft-plugin",
"version": "2.0.0-beta.3",
"version": "2.0.0-beta.4",
"keywords": [
"craft",
"cms",
Expand Down
16 changes: 9 additions & 7 deletions src/ColorExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use craft\services\Assets;
use craft\services\Plugins;
use craft\events\PluginEvent;
use craft\events\GetAssetUrlEvent;
use craft\events\ModelEvent;
use craft\events\ReplaceAssetEvent;
use craft\console\Application as ConsoleApplication;

Expand Down Expand Up @@ -71,12 +71,14 @@ function (ReplaceAssetEvent $event) {
);

Event::on(
Assets::class,
Assets::EVENT_GET_ASSET_URL,
function (GetAssetUrlEvent $event) {
/** @var Asset $element */
$asset = $event->asset;
$this->assetUpload->onSaveAsset($asset);
Asset::class,
Asset::EVENT_AFTER_SAVE,
function (ModelEvent $event) {
if ($event->isNew) {
/** @var Asset $element */
$asset = $event->sender;
$this->assetUpload->onSaveAsset($asset);
}
}
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/AssetUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class AssetUpload extends Component
{
public function onReplaceFile(Asset $asset)
{
if ($asset->kind === 'image' && $asset->mimeType !== 'image/svg+xml') {
if ($asset->kind === Asset::KIND_IMAGE && $asset->mimeType !== 'image/svg+xml') {
$this->createTask($asset->id);
}
}

public function onSaveAsset(Asset $asset)
{
if ($asset->kind === 'image' && $asset->mimeType !== 'image/svg+xml') {
if ($asset->kind === Asset::KIND_IMAGE && $asset->mimeType !== 'image/svg+xml') {
$this->createTask($asset->id);
}
}
Expand Down

0 comments on commit c7e8509

Please sign in to comment.