我希望实现类似于Facebook中的功能,您可以在其中发布视频。所以,当你复制链接时,Facebook创建某种快照,然后你发布它。我搜索谷歌如何做到这一点,但不幸的是没有遇到任何有用的东西。如何实现Facebook中的后期视频功能
我想知道是否有一些已经实现的插件或教程来执行此类操作。
我发现的唯一例子就像下面使用标记的jQuery库。除此之外还有更优雅的东西吗?
marked.setOptions({
gfm: true,
pedantic: false,
sanitize: true,
highlight: null,
urls: {
youtube : function(text, url) {
var cap;
if((cap = /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/.exec(url))) {
return '<iframe width="420" height="315" src="https://www.youtube.com/embed/' + cap[5] + '" frameborder="0" allowfullscreen</iframe>';
}
},
vimeo : function(text, url) {
var cap;
if((cap = /^.*(vimeo\.com\/)((channels\/[A-z]+\/)|(groups\/[A-z]+\/videos\/))?([0-9]+)/.exec(url))) {
return '<iframe src="https://player.vimeo.com/video/' + cap[5] +'" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
}
},
dailymotion : function(text, url) {
var cap;
if((cap = /^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/.exec(url))) {
return '<iframe frameborder="0" width="480" height="271" src="https://www.dailymotion.com/embed/video/' + cap[2] +'"></iframe>';
}
}
});