Commit 7c13cdc9 by halweg

fix 富文本编解码

parent f21db3e9
......@@ -149,12 +149,27 @@ class MediaFeed extends Template {
public function getMedia() {
$cache = $this->getMediaByCache();
if (!empty($cache)) {
return $cache;
return $this->encodePostContent($cache);
}
$feed = $this->getMediaByApi();
if (isset($feed['data'])) {
$this->cacheFeed($this->_json->serialize($feed));
} else {
return [];
}
return $this->encodePostContent($feed);
}
public function encodePostContent($feed)
{
foreach ($feed['data'] as $index => $row) {
if (isset($row['caption'])) {
$feed['data'][$index]["caption"] = base64_encode($row["caption"]);
}
}
$feed['data'] = array_merge($feed['data'], []);
return $feed;
}
}
\ No newline at end of file
......@@ -270,15 +270,17 @@ $media = $block->getMedia()['data'];
<script>
require([
'jquery', 'ko', 'mage/translate'
], function ($, ko) {
], function ($, ko, _) {
$("#instagram-modal-close").on('click', function () {
$("#instagram-modal").hide()
});
$(".instagram-media-wrapper").on('click', function () {
let data = $(this).data("feed-data");
console.log(data);
let link = data.permalink;
let content = data.caption;
let content = '';
if (data.hasOwnProperty('caption')) {
content = decodeURIComponent(escape(atob(data.caption)));
}
let media = data.media_url;
let date = data.timestamp;
let type = data.media_type;
......@@ -296,5 +298,6 @@ $media = $block->getMedia()['data'];
$("#instagram-caption").html("").html(content);
$("#instagram-modal").show()
});
});
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment