开发者

How do I build an 'embeddable widget'?

My webapp uses both Rails and JS and I would like users to be able to embed the images they upload to any blog/site.

What do I need to know, from a development point-of-view to allow me to create the funct开发者_如何学编程ionality that generates an 'embed' link. It can be either a link like YouTube does, or a JS snippet or anything.

Just want to get a high-level overview of what I need to be able to do and how to proceed.

Thanks.


I would try using iframe. I created a widget which used javascript and I put it all into a single html file hosted on my website. Then I gave away an iframe snippet like this for example...

<iframe src="http://mywesbite.com/myWidget.html"></iframe>

The user can simply place the iframe snippet into their website and that's it!


I'm a little bit late to the party here, but I just wanted to add to Jacob's answer.

You can easily allow the user to customize the embedded content (perhaps choose light on dark vs. dark on light text to more closely match the page's environment/design) by using query params within the iframe src:

<iframe src="http://___.com/widget?theme=light&size=large"></iframe>

of course you'd probably want to build a UI to allow the user to make these distinct changes... you can't expect average user's to do that by hand:)

Vimeo's UI for customizing embedded videos is pretty nice if you want a best case scenario.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜