Skip to content

Instantly share code, notes, and snippets.

Avatar

Nazar Leush nleush

  • http://itteco.com
View GitHub Profile
View WordPress Instant Article transformer rule for Iframely embeds
{"rules":[{
"class": "InteractiveRule",
"selector" : "figure.wp-block-embed",
"properties" : {
"interactive.iframe" : {
"type" : "children",
"selector" : "div.wp-block-embed__wrapper"
}
}
}]
@nleush
nleush / get-amp-scripts.js
Last active Feb 10, 2020
Iframely get amp script
View get-amp-scripts.js
var AMP_COMPONENTS_ON_DEMAND = {
"apester-media": "v0/amp-apester-media-0.1.js",
"brightcove": "v0/amp-brightcove-0.1.js",
"dailymotion": "v0/amp-dailymotion-0.1.js",
"facebook-page": "v0/amp-facebook-page-0.1.js",
"facebook": "v0/amp-facebook-0.1.js",
"gfycat": "v0/amp-gfycat-0.1.js",
"gist": "v0/amp-gist-0.1.js",
"iframe": "v0/amp-iframe-0.1.js",
View twitter-error-check.js
var t = window.twttr = window.twttr || {};
t._e = t._e || [];
t.ready = function(f) {
t._e.push(f);
};
twttr.ready(function (twttr) {
twttr.events.bind(
'loaded',
function (event) {
View Add_UTM_params_to_URL___Iframely_Wordpress.php
# Bypass oEmbed sandbox for store links, add UTM params into the summary card
add_filter( 'pre_oembed_result', 'add_utm_params_to_barstool_store', PHP_INT_MAX, 3 );
function add_utm_params_to_barstool_store ( $result, $url, $args ) {
if ( strpos($url, 'https://store.barstoolsports.com') !== false && strpos($url, 'utm_') === false ) {
$api_key = trim( get_site_option( 'iframely_api_key' ) );
$link = $url;
$link = add_query_arg( array(
'utm_source' => 'barstoolsports',
View iframely-webview.js
// use as
// <EmbedWebView
// html = ".. html codes you get from Iframely .."
// />
import React, { Component } from 'react';
import { WebView, View } from 'react-native';
// will receive height data from WebView
function parseMessage(data) {
@nleush
nleush / app.js
Last active Jul 26, 2019
CKEditor 5 script with MediaEmbed configured to use Iframely
View app.js
import MediaEmbed from '@ckeditor/ckeditor5-media-embed/src/mediaembed';
var IFRAME_SRC = '//cdn.iframe.ly/api/iframe';
var API_KEY = '...';
// Your API key from https://iframely.com/profile';
var editorInstance;
ClassicEditor
.create( document.querySelector( '#editor' ), {
@nleush
nleush / iframely-iframe-onload-event.js
Created Dec 11, 2017
'onload' event example for Iframely iframe
View iframely-iframe-onload-event.js
var receiveMessage = function(callback) {
function cb(e) {
var message;
try {
message = JSON.parse(e.data);
} catch (ex) {
}
callback(e, message);
@nleush
nleush / iframely-load-event.html
Created Oct 2, 2017
Example of using iframely.events.on('heightChanged') event with dynamic embed.js script loading.
View iframely-load-event.html
<script>
var iframely = window.iframely = window.iframely || {};
var widgets = iframely.widgets = iframely.widgets || {};
function iframelyLoaded() {
iframely.events.on('heightChanged', function(iframe, oldHeight, newHeight) {
// your handler here, like
// adjustScroll(newHeight - oldHeight);
// iframe is a dom element, heights are numbers
@nleush
nleush / exec_body_scripts.js
Last active Dec 10, 2018
native javascript insert <script> (code or link) in DOM
View exec_body_scripts.js
function exec_body_scripts(body_el) {
function nodeName(elem, name) {
return elem.nodeName && elem.nodeName.toUpperCase() ===
name.toUpperCase();
}
function evalScript(elem) {
var data = (elem.text || elem.textContent || elem.innerHTML || "" ),
script = document.createElement("script");
View iframely-react.js
// Include Iframely embed.js in your page using preferred method. E.g.:
// <script src="//cdn.iframe.ly/embed.js?api_key=[your key here]"></script>
// Add following methods to your component.
componentDidMount: function() {
// Builds widget after embed code rendered.
window.iframely && iframely.load();
},