Skip to content

Commit

Permalink
Version 1.0.3 - tolerate Embedded Assets plugin not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
marionnewlevant committed Dec 23, 2020
1 parent 6d91c03 commit 4484edd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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": "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",
Expand Down
13 changes: 8 additions & 5 deletions src/services/EmbeddedAssetsLinkService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4484edd

Please sign in to comment.