diff --git a/src/fields/ShortLink.php b/src/fields/ShortLink.php index a40e8933..50182bef 100644 --- a/src/fields/ShortLink.php +++ b/src/fields/ShortLink.php @@ -15,6 +15,7 @@ use craft\base\InlineEditableFieldInterface; use craft\base\PreviewableFieldInterface; use craft\helpers\ElementHelper; +use craft\helpers\Json; use craft\helpers\UrlHelper; use nystudio107\retour\Retour as RetourPlugin; use yii\helpers\StringHelper; @@ -102,6 +103,10 @@ public function getSettingsHtml(): string */ public function getPreviewHtml($value, ElementInterface $element): string { + $decoded = Json::decodeIfJson($value); + if (is_array($decoded)) { + $value = $decoded['legacyUrl'] ?? ''; + } // Render the preview template return Craft::$app->getView()->renderTemplate( 'retour/_components/fields/ShortLink_preview',