Shadowboxes for IFRAMEs (SOLVED)


(Emmanuel Schanzer) #1

We run a community site for teachers who are using the Bootstrap curriculum to teach computer science inside mainstream math, science, and social studies classes. Our IDE is cloud-based, so we have the ability to embed an instance of it inside a post on Discourse – this is freaking awesome, and we’re already thrilled to have moved to the platform based on this one feature alone. :slight_smile:

However, there’s plenty of content we’d like to embed this way, and some of it is wider than the post width will allow. Customizing the CSS to permit wider posts hasn’t been fruitful, and ultimately what I’d love is for IFRAMEs to be treated the same way as images: a thumbnail is shown, but clicking it opens a shadowbox that’s as wide as the browser window.

I’ve never messed with Discourse plugin development before, but I could also imagine some kind of Onebox extension that takes URLs matching a particular pattern and generates the appropriate markup. Perhaps there’s an easier way? Curious if anyone else has run into this use-case.


(Jeff Atwood) #2

Maybe @Johani would have some ideas. In general heavy embedding of live content is a bad idea, whereas “click-to-load” like codepen does is more ideal:

huh well darn looks like we regressed a bit there I thought codepen was whitelisted out of the box? can you check @techapj?


(Emmanuel Schanzer) #5

Thank you both for the quick reply!

@craigomez, I might be misreading your post, but it sounds like you’re suggesting I modify the source of the page I’m embedding, in order to have links in that page open in a shadowbox. Is that right? If so, let me clarify that I don’t want that – rather, I want the enclosing IFRAME (a node in the rendered topic, which just happens to contain another page) to be in a shadowbox. And if that’s not right, and I misunderstood, my apologies. :slight_smile:

@codinghorror, click-to-load is a mighty fine solution. Happy to pursue that option, if there’s a resource somewhere to follow?


(Arpit Jalan) #6

This is because we now explicitly require the iframe origin URL to be present in allowed iframes site setting to allow onebox embeds. I added https://codepen.io/ in allowed iframes setting here on meta and rebuilding your post now shows CodePen iframe.

Should we ship https://codepen.io/ by default in allowed iframes site setting?


(Jeff Atwood) #7

I think we should since we specifically worked with them to make the onebox click to load.


(Arpit Jalan) #8

Okay, done. CodePen iframes are now allowed by default.


(Sam Saffron) #9

It would be super cool if you could maximize without needing to visit the site, I wonder if this is a feature @chriscoyier would be interested in adding, not sure how it would be wrangled, but it makes sense for this example you made, for sure.


(Emmanuel Schanzer) #10

I’d love to make our editor click-to-load. Is there an example somewhere for how this was done with CodePen? I’m assuming whitelisting WeScheme.org in our installation is the least of the steps needed.


(Dave McClure) #11

check out this previous post/topic for additional context:

Seems like that is done on the codepen side?

Make the preview “Click-to-Load” : Check the checkbox next to “use click-to-load” to enable the preview version for your embedded Pen. Preview embeds show a static image preview of your Pen with a “Run Pen” button. When your visitors click the button, the Pen will load.

via: Embedded Pens - CodePen Blog


(Joe) #12

This is now possible with a theme component:


(Emmanuel Schanzer) #13

Very interesting! I was able to install the theme using the linked directions (thanks!), but I don’t see a UI for editing the theme settings in order to whitelist my site. Any suggestions for where I should be looking? Thanks in advance!


(Joe) #14

If you’ve installed the theme and cannot see the settings area, then that probably means you’re on a version of Discourse that does not support theme settings.

Even if you’re on the stable branch, the latest release, 2.0, supports theme settings so I would suggest you update Discourse and try again.


(Emmanuel Schanzer) #15

Success! Thanks so much, @Johani! And thanks to everyone else who chimed in with suggestions and advice!