Here is a plugin to enable embeds for Infogram URLs. Simply paste the URL on your page and it will become an embed on your site.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Infogram oEmbed | |
Plugin URI: | |
Description: Adds oEmbed support for infogr.am and infogram.com urls. | |
Author: khromov | |
Version: 1.0 | |
Author URI: https://khromov.se | |
*/ | |
wp_oembed_add_provider('https://infogr.am/*', 'https://infogr.am/oembed_iframe'); | |
wp_oembed_add_provider('https://infogram.com/*', 'https://infogram.com/oembed_iframe'); | |
add_action('wp_footer', function() { | |
?> | |
<script> | |
window.addEventListener('message', function(e) { | |
let data; | |
try { | |
data = JSON.parse(e.data); | |
} catch (e) { | |
return false; | |
} | |
if (data.context !== 'iframe.resize') { | |
return false; | |
} | |
let iframe = document.querySelector('iframe[src="' + data.src + '"]'); | |
if (!iframe) { | |
return false; | |
} | |
iframe.height = data.height; | |
}); | |
</script> | |
<?php | |
}); |