2013-04-08 20 views
0

我發現這個jQuery解決方案可以自動覆蓋真實圖像上的透明gif。在Fancybox框架內自動覆蓋真實圖像的透明gif

http://www.dwuser.com/education/content/stop-the-thieves-strategies-to-protect-your-images/

( 「欺瞞下載」)

它工作正常,在我的WordPress網站(訴3.5.1)用的fancybox插件(訴1.3.4)。

但現在與圖像有關的所有我的鏈接都不見了...

是否有任何解決方案,以保持與圖像有關的活動鏈接?

我也試圖覆蓋GIF屬性只對的fancybox框架內的圖像,但沒有成功......

>>編輯發佈關聯CODE < <

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<script type="text/javascript"> 
$(function() { 
    var pixelSource = 'http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif'; 
    var useOnAllImages = true; 
    // Preload the pixel 
    var preload = new Image(); 
    preload.src = pixelSource; 
    $('img').live('mouseenter touchstart', function(e) { 
     // Only execute if this is not an overlay or skipped 
     var img = $(this); 
     if (img.hasClass('protectionOverlay')) return; 
     if (!useOnAllImages && !img.hasClass('protectMe')) return; 
     // Get the real image's position, add an overlay 
     var pos = img.offset(); 
     var overlay = $('<img class="protectionOverlay" src="' + pixelSource + '" width="' + img.width() + '" height="' + img.height() + '" />').css({position: 'absolute', zIndex: 9999999, left: pos.left, top: pos.top}).appendTo('body').bind('mouseleave', function() { 
      setTimeout(function(){ overlay.remove(); }, 0, $(this)); 
     }); 
     if ('ontouchstart' in window) $(document).one('touchend', function(){ setTimeout(function(){ overlay.remove(); }, 0, overlay); }); 
    }); 
}); 
</script> 

感謝和對不起我的英文不好。 d。

+0

你可以嘗試,以防止潛在的小偷,但遺憾的是沒有用JavaScript真正的保護(我可以下載任何圖像你的網站無論你怎麼努力欺騙我。)最好的辦法是找到一個服務器端解決方案,如果你不想手動添加水印,它可以即時爲你的圖像添加水印。潛在的盜賊仍然可以下載你的水印圖像。 – JFK 2013-04-08 15:38:08

+0

檢查http://fancyapps.com/fancybox/#useful第4代的代碼示例添加水印和禁用右鍵單擊,如果這有助於您的安心;) – JFK 2013-04-08 15:40:15

回答

0

在您的圖像上放置水印一個選項? 當你在圖像上放置一個gif時,你可以用鼠標右鍵來保存圖像。 但用Firefox你可以右鍵點擊任何地方並選擇'查看頁面信息',然後從那裏的標籤媒體,你仍然可以下載圖像。

PS: 或者JS禁用的人也可以下載圖像。

+0

嗨,我感謝你的答案。 我想添加一個透明圖層到我的圖片,以防止下載(我知道安全水平相當低)。 我也將純粹的美學原因避免與水印的解決方案。 – deivz 2013-04-08 14:40:41

0

試試這個:{要知道,任何JavaScript的保護是無用的,經驗豐富的developpers}

$(function() { 
    var pixelSource = 'http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif'; 
    var useOnAllImages = true; 
    // Preload the pixel 
    var preload = new Image(); 
    preload.src = pixelSource; 
    //live is deprecated, use 'on' instead 
    $(document).on('mouseenter touchstart','img', function(e) { 
     // Only execute if this is not an overlay or skipped 
     var img = $(this); 
     if (img.hasClass('protectionOverlay')) return; 
     if (!useOnAllImages && !img.hasClass('protectMe')) return; 
     // Get the real image's position, add an overlay 
     var pos = img.offset(); 
     var overlay = $('<img class="protectionOverlay" src="' + pixelSource + '" width="' + img.width() + '" height="' + img.height() + '" />').css({position: 'absolute', zIndex: 9999999, left: pos.left, top: pos.top}).appendTo('body').bind('mouseleave', function() { 
      setTimeout(function(){ overlay.remove(); }, 0, $(this)); 
     }).click(function(){ 
      if(img.parent('a').length)//assuming your image is embeded in a link tag 
       window.location.replace(img.parent('a').attr('href')); 
     }); 
     if ('ontouchstart' in window) $(document).one('touchend', function(){ setTimeout(function(){ overlay.remove(); }, 0, overlay); }); 
    }); 
}); 
+0

嗨烤了。我感謝你的幫助。 不幸的是,您提出的版本似乎與原始版本完全一樣:與圖像相關的鏈接保持不活動狀態... – deivz 2013-04-08 14:51:44

+0

您應該發佈圖像的html代碼,我的意思是如何設置圖像鏈接? – 2013-04-08 14:54:51

+0

我的傳統方式: deivz 2013-04-08 14:59:41