Skip to content

Commit db59ce7

Browse files
committed
Fix an error saving Media Embed nodes containing emoji’s in their payload data
1 parent 6d3b9af commit db59ce7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/nodes/MediaEmbed.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
namespace verbb\vizy\nodes;
33

44
use verbb\vizy\base\Node;
5+
use verbb\vizy\helpers\StringHelper;
6+
7+
use craft\base\ElementInterface;
8+
use craft\helpers\Json;
59

610
class MediaEmbed extends Node
711
{
@@ -18,4 +22,14 @@ public function renderNode(array $config = []): ?string
1822
{
1923
return $this->attrs['data']['html'] ?? null;
2024
}
25+
26+
public function serializeValue(ElementInterface $element = null): ?array
27+
{
28+
$value = parent::serializeValue($element);
29+
30+
// In case the payload contains emoji's, the field will throw an error
31+
$value = Json::decode(StringHelper::emojiToShortcodes(Json::encode($value)));
32+
33+
return $value;
34+
}
2135
}

0 commit comments

Comments
 (0)