Skip to content

Commit cea3b83

Browse files
committed
Added the logic for Pinmarklet custom images.
1 parent 9ddca53 commit cea3b83

File tree

6 files changed

+444
-2
lines changed

6 files changed

+444
-2
lines changed

README.md

+55-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,57 @@
1-
Pinmarklet
1+
Pinmarklet Custom Images
22
==========
33

4-
Script that allow to share custom images on Pinterest
4+
Script based on the original pinmarklet for Pinterst allows to share custom images on Pinterest
5+
<br/>
6+
The script uses jQuery.
7+
8+
##Usage:
9+
### Add the scripts required
10+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
11+
<script type="text/javascript" src="pinmarklet.js"></script>
12+
13+
### Add a link as:
14+
<a id="pinterest" href="#"><img src="images/PinExt.png"></a>
15+
16+
> The link will be as:
17+
<a id="pinterest" href="#"><img src="images/PinExt.png"></a>
18+
19+
20+
21+
### Handle the event on click with jQuery
22+
23+
<script type="text/javascript">`
24+
$("#pinterest").click(function(){
25+
var imgArray = {
26+
images: [
27+
{
28+
src: "https://lh6.ggpht.com/oJ-bWH2rXcm4OozwnAxatnyBMIjbNDGtZtmvvzTgwzz7gYUI4Rm1_U7uUS0Q5xCMOj8=w124",
29+
alt: "Image from Google Images"
30+
},
31+
{
32+
src: "https://lh6.ggpht.com/_lTfuXOfXmr6ltzuSnKKMJ7sgTYcxAAsrRZOXUHnm3-ANUTIPvYoEo2De04LV95jDqc=h230",
33+
alt: "Image from Google Images"
34+
}
35+
]
36+
};
37+
38+
UTIL.pinterest.addPinMarklet({
39+
images : imgArray.images
40+
});
41+
return false;
42+
});
43+
</script>
44+
45+
### Add login onPin
46+
If requires execute a function when the image is clicked for share with pinterest add a function onPin
47+
48+
UTIL.pinterest.addPinMarklet({
49+
images : imgArray.images,
50+
onPin : function(){
51+
console.log("onPin event you can execute whatever you need");
52+
}
53+
});
54+
55+
### Exemple
56+
57+
There are a simple example on <pre><code>index.html</code></pre>

images/LogoRed.png

2.62 KB
Loading

images/PinExt.png

936 Bytes
Loading

images/button.png

2.78 KB
Loading

index.html

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE>
2+
<html>
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5+
<title>Insert title here</title>
6+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
7+
<script type="text/javascript" src="pinmarklet.js"></script>
8+
</head>
9+
10+
<body>
11+
<p>Photo gallery</p>
12+
<ul >
13+
<li style="display: inline;"><img src="https://lh6.ggpht.com/oJ-bWH2rXcm4OozwnAxatnyBMIjbNDGtZtmvvzTgwzz7gYUI4Rm1_U7uUS0Q5xCMOj8=w124" alt="Shape'd image" /></li>
14+
<li style="display: inline;"><img src="https://lh6.ggpht.com/_lTfuXOfXmr6ltzuSnKKMJ7sgTYcxAAsrRZOXUHnm3-ANUTIPvYoEo2De04LV95jDqc=h230" /></li>
15+
<li style="display: inline;"><img src="https://lh6.ggpht.com/cJc0ziefWgLEFzqftXVfwHpsj7xgQYDfuvJAKEGVBS34FA_UVlXieDKTFy-2KxYNAEM=h230" /></li>
16+
<li style="display: inline;"><img src="https://lh5.ggpht.com/PsBg95GrXk3fgywMSYQ01efNDLyQ87vjV4d12Be03975CU5a5VCuC1fDdHxueAIWc-w=h230" /></li>
17+
</ul>
18+
19+
20+
<p>Having these images usually we will want to just share the first and second images, so we can pass these images to the function</p>
21+
<p>On the event onClick when share with Pinterest the image there is a function that print in console</p>
22+
23+
<a id="pinterest" href="#"><img src="images/PinExt.png"></a>
24+
<script type="text/javascript">
25+
//map the object to a default img
26+
$("#pinterest").click(function(){
27+
var imgArray = {
28+
images: [
29+
{
30+
src: "https://lh6.ggpht.com/oJ-bWH2rXcm4OozwnAxatnyBMIjbNDGtZtmvvzTgwzz7gYUI4Rm1_U7uUS0Q5xCMOj8=w124",
31+
alt: "Image from Google Images"
32+
},
33+
{
34+
src: "https://lh6.ggpht.com/_lTfuXOfXmr6ltzuSnKKMJ7sgTYcxAAsrRZOXUHnm3-ANUTIPvYoEo2De04LV95jDqc=h230",
35+
alt: "Image from Google Images"
36+
}
37+
]
38+
};
39+
40+
UTIL.pinterest.addPinMarklet({
41+
images : imgArray.images,
42+
onPin : function(){
43+
console.log("onPin event you can execute whatever you need");
44+
}
45+
});
46+
return false;
47+
});
48+
</script>
49+
</body>
50+
</html>

0 commit comments

Comments
 (0)