Version Description
- Added code that works when javascript creates or loads a new image. Disabled drag and drop on images so images can't be dragged to desktop.
=
Download this release
Release Info
Developer | kpgraham |
Plugin | No Right Click Images Plugin |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.2
- no-right-click-images-plugin.php +33 -17
- readme.txt +5 -1
no-right-click-images-plugin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: No Right Click Images Plugin
|
4 |
Plugin URI: http://www.BlogsEye.com/
|
5 |
Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
|
6 |
-
Version: 1.
|
7 |
Author: Keith P. Graham
|
8 |
Author URI: http://www.BlogsEye.com/
|
9 |
|
@@ -27,17 +27,35 @@ function kpg_no_rc_img_fixup() {
|
|
27 |
function kpg_nrci_context(event) {
|
28 |
//alert("context");
|
29 |
var ev=event||window.event;
|
|
|
|
|
|
|
|
|
|
|
30 |
ev.returnValue=false;
|
31 |
return false;
|
32 |
}
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
var ev=event||window.event;
|
36 |
-
if (
|
37 |
-
//alert ("left");
|
38 |
ev.returnValue=false;
|
|
|
|
|
|
|
|
|
|
|
39 |
return false;
|
40 |
-
|
41 |
return true;
|
42 |
}
|
43 |
// sets the image onclick event
|
@@ -46,8 +64,16 @@ function kpg_no_rc_img_fixup() {
|
|
46 |
var b=document.getElementsByTagName("IMG");
|
47 |
for (var i = 0; i < b.length; i++) {
|
48 |
b[i].oncontextmenu=function(event) { return kpg_nrci_context(event);}
|
|
|
|
|
49 |
}
|
50 |
} catch (ee) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
// set the onload event
|
53 |
if (document.addEventListener) {
|
@@ -63,16 +89,6 @@ function kpg_no_rc_img_fixup() {
|
|
63 |
kpg_nrci_action('load');
|
64 |
};
|
65 |
}
|
66 |
-
function kpgremoveHTMLTags(ihtml){
|
67 |
-
try {
|
68 |
-
ihtml = ihtml.replace(/&(lt|gt);/g, function (strMatch, p1){
|
69 |
-
return (p1 == "lt")? "<" : ">";
|
70 |
-
});
|
71 |
-
return ihtml.replace(/<\/?[^>]+(>|$)/g, "");
|
72 |
-
} catch (eee) {
|
73 |
-
return '';
|
74 |
-
}
|
75 |
-
}
|
76 |
// end of No Right Click Images Plugin
|
77 |
// -->
|
78 |
</script>
|
@@ -90,7 +106,7 @@ function kpg_no_rc_img_control() {
|
|
90 |
<div class="wrap">
|
91 |
<h2>No Right Click Images Plugin</h2>
|
92 |
<h4>The No Right Click Images Plugin is installed and working correctly.</h4>
|
93 |
-
<p>This plugin installs some javascript in the footer of every page. When your page finishes loading, the javascript steps through the
|
94 |
<p>There are no configurations options. The plugin is on when it is installed and enabled. To turn it off just disable the plugin from the plugin menu.. </p>
|
95 |
|
96 |
<hr/>
|
3 |
Plugin Name: No Right Click Images Plugin
|
4 |
Plugin URI: http://www.BlogsEye.com/
|
5 |
Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
|
6 |
+
Version: 1.2
|
7 |
Author: Keith P. Graham
|
8 |
Author URI: http://www.BlogsEye.com/
|
9 |
|
27 |
function kpg_nrci_context(event) {
|
28 |
//alert("context");
|
29 |
var ev=event||window.event;
|
30 |
+
var targ=ev.srcElement||ev.target;
|
31 |
+
ev.returnValue=false;
|
32 |
+
if (ev.preventDefault) {
|
33 |
+
ev.preventDefault();
|
34 |
+
}
|
35 |
ev.returnValue=false;
|
36 |
return false;
|
37 |
}
|
38 |
+
var targImg=null;
|
39 |
+
function kpg_nrc1_mousedown(event) {
|
40 |
+
var ev=event||window.event;
|
41 |
+
var targ=ev.srcElement||ev.target;
|
42 |
+
if (targ.tagName=="IMG"||targ.tagName=="img") {
|
43 |
+
targImg=targ;
|
44 |
+
}
|
45 |
+
return true
|
46 |
+
}
|
47 |
+
function kpg_nrci_contextAll(event) {
|
48 |
+
if (targImg==null) return true;
|
49 |
var ev=event||window.event;
|
50 |
+
if (targImg.tagName=="IMG"||targImg.tagName=="img") {
|
|
|
51 |
ev.returnValue=false;
|
52 |
+
if (ev.preventDefault) {
|
53 |
+
ev.preventDefault();
|
54 |
+
}
|
55 |
+
ev.returnValue=false;
|
56 |
+
targImg=null;
|
57 |
return false;
|
58 |
+
}
|
59 |
return true;
|
60 |
}
|
61 |
// sets the image onclick event
|
64 |
var b=document.getElementsByTagName("IMG");
|
65 |
for (var i = 0; i < b.length; i++) {
|
66 |
b[i].oncontextmenu=function(event) { return kpg_nrci_context(event);}
|
67 |
+
b[i].onmousedown=function(event) { return kpg_nrc1_mousedown(event);}
|
68 |
+
b[i].ondragstart=function() { return false;}
|
69 |
}
|
70 |
} catch (ee) {}
|
71 |
+
// set the document onclick in case someone loads a new image
|
72 |
+
document.onmousedown=function(event) { return kpg_nrc1_mousedown(event);}
|
73 |
+
document.oncontextmenu=function(event) { return kpg_nrci_contextAll(event);}
|
74 |
+
// other events
|
75 |
+
document.ondragstart=function(event) { return kpg_nrci_contextAll(event);}
|
76 |
+
|
77 |
}
|
78 |
// set the onload event
|
79 |
if (document.addEventListener) {
|
89 |
kpg_nrci_action('load');
|
90 |
};
|
91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
// end of No Right Click Images Plugin
|
93 |
// -->
|
94 |
</script>
|
106 |
<div class="wrap">
|
107 |
<h2>No Right Click Images Plugin</h2>
|
108 |
<h4>The No Right Click Images Plugin is installed and working correctly.</h4>
|
109 |
+
<p>This plugin installs some javascript in the footer of every page. When your page finishes loading, the javascript steps through the tags on the page looking for Images and sets them so the context menu won't appear.</p>
|
110 |
<p>There are no configurations options. The plugin is on when it is installed and enabled. To turn it off just disable the plugin from the plugin menu.. </p>
|
111 |
|
112 |
<hr/>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://online.nwf.org/site/Donation2?df_id=6620&6620.donation=form
|
|
4 |
Requires at least: 2.2
|
5 |
Tested up to: 3.0
|
6 |
Contributors: Keith Graham
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Disables right click context menu on images to help deter leeches from glomming images.
|
10 |
|
@@ -24,6 +24,10 @@ It is impossible to keep people from stealing images that appear in web pages, b
|
|
24 |
|
25 |
= 1.0 =
|
26 |
* initial release
|
|
|
|
|
|
|
|
|
27 |
|
28 |
|
29 |
== Support ==
|
4 |
Requires at least: 2.2
|
5 |
Tested up to: 3.0
|
6 |
Contributors: Keith Graham
|
7 |
+
Stable tag: 1.2
|
8 |
|
9 |
Disables right click context menu on images to help deter leeches from glomming images.
|
10 |
|
24 |
|
25 |
= 1.0 =
|
26 |
* initial release
|
27 |
+
= 1.1 =
|
28 |
+
* deleted some unused code in the javascript
|
29 |
+
= 1.2 =
|
30 |
+
* Added code that works when javascript creates or loads a new image. Disabled drag and drop on images so images can't be dragged to desktop.
|
31 |
|
32 |
|
33 |
== Support ==
|