這是後"Direct link to any fancybox", but with URL in address bar。現在,我設法爲我的fancybox圖庫的每個圖像分配一個唯一的網址,我想知道是否通過分享例如圖片#1的網址,它會產生正確的拇指,例如,在Facebook上。指定fancybox的網址的拇指(圖片)
我正在使用最新的fancybox和jQuery版本。
這裏是JavaScript:
var thisHash = window.location.hash;
$(document).ready(function() {
$('.thumbs').fancybox({
prevEffect : 'fade',
nextEffect : 'fade',
closeBtn : true,
arrows : true,
nextClick : true,
padding : 15,
helpers : {
title : {
type : 'inside'
},
thumbs : {
width : 80,
height : 80
}
},
beforeShow: function() {
var id = this.element.attr("id")
if (id) {
window.location.hash = id;
}
},
beforeClose: function() {
window.location.hash = "";
}
});
if(thisHash) {
$(thisHash).trigger('click');
}
});
這裏是HTML:
<a class="thumbs" data-fancybox-group="group1" id="image1" href="http://freeimagesarchive.com/data/media/206/1_black.jpg"><img src="http://freeimagesarchive.com/data/media/206/1_black.jpg" /></a>
基本上,這段代碼,當我打開圖像,該網址將成爲如www.mysite.com#image1
如果我複製該地址並粘貼,例如Facebook,顯然它不會給任何拇指分享。正確的拇指將是http://freeimagesarchive.com/data/media/206/1_black.jpg,但這個想法不是分享圖像鏈接,而是fancybox鏈接。
我希望自己清楚,對不起英文。
任何方式來做到這一點?
嗨,謝謝你的回答。事情是,我已經有了一個獨特的每個圖像的網址,不能這樣工作嗎?沒有辦法爲每個../#image生成og標籤嗎? – coldpumpkin
@coldpumpkin幾年後,我在這裏跟隨你的腳步。你有沒有想過這個? – dotcommer
@dotcommer不,我沒有:\ \ – coldpumpkin