Consider.it integration in discourse

There is one, hopefully final, hurdle to fully working considerit oembed: consistent iframe resizing.

Embedding in a Discourse thread works sometimes. But it often doesn’t run the javascript that invokes the resizing.

I haven’t pinned it down, but here is one curious way I can replicate in Discourse:

  • doesn’t resize if I just load a thread with a considerit link
  • if I have the editor open for the post with the link, the iframe resize works in the thread (but not the preview)

This holds true across refreshes.

So there’s something special that seems to happen in Discourse during edit post mode.

I recorded this riveting 40 second video to demonstrate the behavior.

I’ve had a frustrating past several hours trying to figure it out. If anyone has insights, I would really appreciate it!

Thanks,
Travis


Background:

From my earlier post, the oembed html snippet that considerit returns includes: “…mostly just an iframe…The HTML also loads a small javascript library into the containing window which resizes the iframe whenever the content inside the iframe changes height. The author of this library asserts that the library is engineered to play nicely with the containing window.”

The specific code is e.g. :

   <iframe id='considerit-embed-4186' src='https://dao.consider.it/embed/proposal/slockit1' width='700' frameborder='0' style='overflow:hidden' scrolling='no'></iframe>
   <script src='https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.5.3/iframeResizer.min.js'></script>
   <script type='application/javascript'>
     var resize_interval=setInterval(function(){
       if (typeof iFrameResize != 'undefined'){
         iFrameResize({log:false, checkOrigin:false}, document.getElementById('considerit-embed-4186'))
         clearInterval(resize_interval)
       }
     }, 40)
   </script>
3 Likes