diff --git a/CHANGELOG.md b/CHANGELOG.md index 538fa8d8..de4876ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes for Campaign +## 3.4.3 - Unreleased + +### Changed + +- Contact avatars are now fetched from unavatar.io instead of gravatar.com, and a fallback SVG with initials is used if none is found. + ## 3.4.2 - 2024-08-02 ### Changed diff --git a/composer.json b/composer.json index 084be03b..c4328186 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "putyourlightson/craft-campaign", "description": "Send and manage email campaigns, contacts and mailing lists.", - "version": "3.4.2", + "version": "3.4.3", "type": "craft-plugin", "homepage": "https://putyourlightson.com/plugins/campaign", "license": "proprietary", diff --git a/src/assets/CpAsset.php b/src/assets/CpAsset.php index 35398fae..8648fcc1 100644 --- a/src/assets/CpAsset.php +++ b/src/assets/CpAsset.php @@ -28,13 +28,6 @@ class CpAsset extends AssetBundle CraftCpAsset::class, ]; - /** - * @inheritdoc - */ - public $css = [ - 'css/cp.css', - ]; - /** * @inheritdoc */ diff --git a/src/elements/ContactElement.php b/src/elements/ContactElement.php index e17c38ac..e251f376 100755 --- a/src/elements/ContactElement.php +++ b/src/elements/ContactElement.php @@ -462,7 +462,7 @@ protected function defineRules(): array */ public function getPostEditUrl(): ?string { - return UrlHelper::cpUrl("campaign/contacts"); + return UrlHelper::cpUrl('campaign/contacts'); } /** @@ -895,20 +895,32 @@ public function getStatus(): ?string } /** - * @inheritdoc + * Returns an image from unavatar.io, with an SVG behind it as a fallback. + * + * @see User::getThumbHtml() */ - public function thumbUrl(int $size): ?string + public function getThumbHtml(int $size): ?string { - // Get image from Gravatar, defaulting to a blank image - return 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($this->email))) . '?d=blank&s=' . $size; - } + $value = strtolower(trim($this->email)); + $image = Html::img('https://unavatar.io/' . $value . '?fallback=false', [ + 'width' => $size, + 'height' => $size, + ]); - /** - * @inheritdoc - */ - public function hasRoundedThumb(): bool - { - return true; + $initials = mb_strtoupper(mb_substr(str_replace('@', '', $value), 0, 2)); + $svg = << + + $initials + + XML; + + $options = [ + 'class' => 'thumb rounded', + ]; + + return Html::tag('div', $svg, $options) + . Html::tag('div', $image, $options + ['style' => 'position: absolute']); } /** diff --git a/src/resources/css/cp.css b/src/resources/css/cp.css deleted file mode 100644 index 47278c4d..00000000 --- a/src/resources/css/cp.css +++ /dev/null @@ -1,5 +0,0 @@ -.element.hasthumb[data-type="putyourlightson\\campaign\\elements\\ContactElement"] .elementthumb { - background: url('../images/user.svg'); - background-size: cover; - border-radius: 50%; -}