在我的 HTML 文档中,我想为图像创建一个占位符,但保留源“待定”,这样当我在图像上放置链接时,它将从目标网站获取快照以用作图像源。如果您不太明白我在说什么,如下所示:
我想创建一个链接图像

并且我想使用 javascript 将“源”替换为“#”页面的快照。
我想使用它,以便在我的网站上我可以链接到 Youtube 视频(使用嵌入代码中的链接)并自动获取链接的缩略图,而无需输入链接/URL 之外的任何工作。
我不太懂 JavaScript,所以任何有关该部分的帮助将不胜感激,尽管如果可能的话,我会尝试使用非常少的 JavaScript 来完成此操作。非常感谢所有答案,如果需要更多信息,请询问。
In my HTML document I want to create a placeholder for an image but leave the source 'To be determined' so to speak so that when I put a link on the image it will acquire a snapshot from the target website to use as the image source. If you don't quite understand what I'm saying it is as follows:
I want to create a linked Image
<a href="#"><img src="source"></a>
and I want to use javascript to replace the 'source' with a snapshot of the '#' page.
I would like to use this so that on my website I can link to Youtube videos (using the link in the embed codes) and automatically acquire a thumbnail for the link without any work more than inputting the link/URL.
I am not very javascript savy so any help with that portion will be much appreciated, although I am trying to do this with very minimal Javascript if possible. All answers are much appreciated and if any more information is needed just ask.
发布评论
评论(3)
如果你想放置 YouTube 屏幕截图,我建议使用 jQuery 和 jYouTube 以及我如何将其组合在一起:
JAVASCRIPT:
HTML
另外,我将其放在 jsfiddle 中以方便演示: http://jsfiddle.net/snyew/
我希望这有帮助:-)
If you want to put YouTube screenshot I recommend using jQuery with jYouTube and here how I put it together:
JAVASCRIPT:
HTML
Also I put it in jsfiddle for easy demo: http://jsfiddle.net/snyew/
I hope this helps :-)
它需要一个 Image 对象。
It takes an Image object.
假设您想对每个仅包含图像作为子项的链接执行此操作,您可以这样做:
上面假设您可以在项目中使用 jQuery。
Assuming you want to do this for every link with just an image as child, you can do:
The above assumes you are ok with using jQuery on the project.