diff --git a/CHANGELOG.md b/CHANGELOG.md index 0346d46..3d6f6eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Embedded Assets Link Changelog +## 1.0.3 - 2020-12-22 +### Fixed +- No error when Embedded Assets plugin not installed + ## 1.0.2 - 2020-11-02 ### Fixed - finished renaming from v 1.0.1 diff --git a/composer.json b/composer.json index 2313ff5..eff4717 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "marionnewlevant/embedded-assets-link", "description": "Adds a link to the Embedded Asset in the Control Panel", "type": "craft-plugin", - "version": "1.0.2", + "version": "1.0.3", "keywords": [ "craft", "cms", diff --git a/src/services/EmbeddedAssetsLinkService.php b/src/services/EmbeddedAssetsLinkService.php index b690a6d..98f7c9e 100644 --- a/src/services/EmbeddedAssetsLinkService.php +++ b/src/services/EmbeddedAssetsLinkService.php @@ -32,12 +32,15 @@ class EmbeddedAssetsLinkService extends Component */ public function assetUrl(int $elementId, string $elementType, int $siteId) { - $element = Craft::$app->elements->getElementById($elementId, $elementType, $siteId); - - $embeddedAsset = EmbeddedAssets::$plugin->methods->getEmbeddedAsset($element); - if ($embeddedAsset) + if (EmbeddedAssets::$plugin) // will be null if embedded assets plugin not installed. { - return $embeddedAsset->url; + $element = Craft::$app->elements->getElementById($elementId, $elementType, $siteId); + + $embeddedAsset = EmbeddedAssets::$plugin->methods->getEmbeddedAsset($element); + if ($embeddedAsset) + { + return $embeddedAsset->url; + } } return null;