更改Twitter和Facebook共享图像点击

时间:2017-01-16 21:00:48

标签: javascript jquery django twitter metadata

我在

的地方
  • 我有一系列30张幻灯片,当你向下滚动页面时,一个锚点 被附加到网址(例如#day1,#day2,#day3 ...#day30)
  • 我正在寻找一种方法来改变meta name="twitter:image和。{ meta property="og:image"所以当用户在slide/#day3和链接时 点击后,网址会显示相应日期的图片day3.jpg
  • 我将从data.js以JSON格式提取每张幻灯片的数据

scripts.js中

$('.twitter-slide').click(function() {
    $('meta[property="og:image"]').attr('content', 'linkToPicture');
});

data.js

var data = [
 {
   "Day": 1,
   "Slide": "#day1",
   "Description": "Hungry by early afternoon. Thinking about all foods as either forbidden or compliant constantly.",
   "Extra": "",
   "Tweet": "Hungry by early afternoon.",
   "Background": "#ffffd9",
   "Font": "#111",
   "Image": ""
 },
 {
   "Day": 2,
   "Slide": "#day2",
   "Description": "Ate a whole avocado and truckful of nuts as late afternoon snack. Still feeling low key hungry.",
   "Extra": "",
   "Tweet": "Ate a whole avocado and truckful of nuts as late afternoon snack.",
   "Background": "#ffffd9",
   "Font": "#111",
   "Image": ""
 },
 {
   "Day": 3,
   "Slide": "#day3",
   "Description": "Have three water-based beverages at my desk: Ice water, hot water and water with lemon.",
   "Extra": "",
   "Tweet": "Have three water-based beverages at my desk: Ice water, hot water and water with lemon.",
   "Background": "#ffffd9",
   "Font": "#111",
   "Image": ""
 }
]

0 个答案:

没有答案