When triggering replace assets, imageX should check the asset type, only attempt to remove asset transforms when the asset is image.
Potentially this can be fixed by changing:
https://github.com/spacecatninja/craft-imager-x/blob/5c130e07a519179dd8f29cda3b53986201017f7e/src/ImagerX.php#L241
With the below code.
```php
// Event listener for clearing caches when an asset is replaced
Event::on(Assets::class, Assets::EVENT_AFTER_REPLACE_ASSET,
static function(ReplaceAssetEvent $event) use ($config) {
// Check if the asset is an image before proceeding
if ($event->asset->kind == 'image') {
ImagerX::$plugin->imagerx->removeTransformsForAsset($event->asset);
// If Imgix purging is possible, do that too
if ($config->imgixEnableAutoPurging && ImgixService::getCanPurge()) {
ImagerX::$plugin->imgix->purgeAssetFromImgix($event->asset);
}
}
}
);
```
### Displayed errors, stack trace, relevant logs
PASTE THE ERROR MESSAGE / STACK TRACE HERE
[TypeError] TypeError: Cannot assign null to property spacecatninja\imagerx\models\LocalSourceImageModel::$url of type string in
/vendor/spacecatninja/imager-x/src/models/LocalSourceImageModel.php:223
Stack trace:
#0 /vendor/spacecatninja/imager-x/src/models/LocalSourceImageModel.php(115): spacecatninja\imagerx\models\LocalSourceImageModel->getPathsForLocalAsset()
#1 /vendor/spacecatninja/imager-x/src/models/LocalSourceImageModel.php(68): spacecatninja\imagerx\models\LocalSourceImageModel->init()
#2 /vendor/spacecatninja/imager-x/src/services/ImagerService.php(667): spacecatninja\imagerx\models\LocalSourceImageModel->__construct()
#3 /vendor/spacecatninja/imager-x/src/ImagerX.php(241): spacecatninja\imagerx\services\ImagerService->removeTransformsForAsset()
#4 [internal function]: spacecatninja\imagerx\ImagerX::spacecatninja\imagerx\{closure}()
#5 /vendor/yiisoft/yii2/base/Event.php(312): call_user_func()
#6 /vendor/yiisoft/yii2/base/Component.php(650): yii\base\Event::trigger()
#7 /vendor/craftcms/cms/src/services/Assets.php(172): yii\base\Component->trigger()
#8 /vendor/craftcms/cms/src/controllers/AssetsController.php(415): craft\services\Assets->replaceAssetFile()
#9 [internal function]: craft\controllers\AssetsController->actionReplaceFile()
#10 /vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#11 /vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#12 /vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction()
#13 /vendor/craftcms/cms/src/web/Application.php(349): yii\base\Module->runAction()
#14 /vendor/craftcms/cms/src/web/Application.php(648): craft\web\Application->runAction()
#15 /vendor/craftcms/cms/src/web/Application.php(311): craft\web\Application->_processActionRequest()
#16 /vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest()
#17 /web/index.php(12): yii\base\Application->run()
#18 {main} {"memory":7538880,"exception":"[object] (TypeError(code: 0): Cannot assign null to property spacecatninja\\imagerx\\models\\LocalSourceImageModel::$url of type string at /vendor/spacecatninja/imager-x/src/models/LocalSourceImageModel.php:223)"}
Steps to reproduce
Description
When triggering replace assets, imageX should check the asset type, only attempt to remove asset transforms when the asset is image. Potentially this can be fixed by changing: https://github.com/spacecatninja/craft-imager-x/blob/5c130e07a519179dd8f29cda3b53986201017f7e/src/ImagerX.php#L241 With the below code. ```php // Event listener for clearing caches when an asset is replaced Event::on(Assets::class, Assets::EVENT_AFTER_REPLACE_ASSET, static function(ReplaceAssetEvent $event) use ($config) { // Check if the asset is an image before proceeding if ($event->asset->kind == 'image') { ImagerX::$plugin->imagerx->removeTransformsForAsset($event->asset); // If Imgix purging is possible, do that too if ($config->imgixEnableAutoPurging && ImgixService::getCanPurge()) { ImagerX::$plugin->imgix->purgeAssetFromImgix($event->asset); } } } ); ``` ### Displayed errors, stack trace, relevant logsAdditional info