Link to “pin it” on pinterest without generating a button

后端 未结 7 1600
时光取名叫无心
时光取名叫无心 2020-12-12 13:18

I have a page with tens or hundreds of posts, each one with social buttons. I just can\'t generate all the buttons for each url: it is too slow (facebook, g+, twitter, pinte

7条回答
  •  醉酒成梦
    2020-12-12 13:49

    You can create a custom link as described here using a small jQuery script

    $('.linkPinIt').click(function(){
        var url = $(this).attr('href');
        var media = $(this).attr('data-image');
        var desc = $(this).attr('data-desc');
        window.open("//www.pinterest.com/pin/create/button/"+
        "?url="+url+
        "&media="+media+
        "&description="+desc,"_blank","top=0,right=0,width=750,height=320");
        return false; 
    });
    

    this will work for all links with class linkPinItwhich have the image and the description stored in the HTML 5 data attributes data-image and data-desc

    
        Pin it!
     
    

    see this jfiddle example

提交回复
热议问题