diff --git a/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/ezfacebook.html.twig b/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/ezfacebook.html.twig index fae0b872..2c6dab11 100644 --- a/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/ezfacebook.html.twig +++ b/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/ezfacebook.html.twig @@ -19,7 +19,10 @@ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; - js.src = 'https://connect.facebook.net/en_EN/sdk.js#xfbml=1&version=v4.0'; + js.src = 'https://connect.facebook.net/en_EN/sdk.js#xfbml=0&version=v21.0'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); + document.body.addEventListener('ibexa-post-update-blocks-preview', () => { + window.FB.XFBML.parse(); + }); diff --git a/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/eztwitter.html.twig b/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/eztwitter.html.twig index 6df34f7c..576f132c 100644 --- a/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/eztwitter.html.twig +++ b/src/bundle/Resources/views/themes/standard/ezrichtext/custom_tags/eztwitter.html.twig @@ -19,10 +19,16 @@ }; return t; }(doc, 'script', 'twitter-wjs')); - const tweetContainer = doc.querySelector('.tweet-container[data-url="{{ params.tweet_url }}"]'); - const tweetUrlParts = tweetContainer.dataset.url.split('/'); - const tweetId = tweetUrlParts[tweetUrlParts.length - 1]; - global.twttr.ready(function () { + const initTwitterWidget = () => { + const tweetContainer = doc.querySelector('.tweet-container[data-url="{{ params.tweet_url }}"]'); + + if (!tweetContainer) { + return; + } + + const tweetUrlParts = tweetContainer.dataset.url.split('/'); + const tweetId = tweetUrlParts[tweetUrlParts.length - 1]; + global.twttr.widgets.createTweet( tweetId, tweetContainer, @@ -37,6 +43,12 @@ 'dnt': '{{ params.dnt is defined ? params.dnt : '' }}', } ); + } + global.twttr.ready(function () { + initTwitterWidget(); + }); + doc.body.addEventListener('ibexa-post-update-blocks-preview', () => { + initTwitterWidget(); }); })(window, window.document);