在自定义twitter分享图标中分享链接,标题和一个图片 [英] Share the link , title and one image in custom twitter share icon

查看:1442
本文介绍了在自定义twitter分享图标中分享链接,标题和一个图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是自定义twitter图标代码:

HTML:

 < i id =twitter_shareclass =fa fa-twitter fs20style =position:relative; bottom:4px;>< / i> 

和jquery:

  $('#twitter_share')。click(function(e){
e.preventDefault();
var loc =<?= base_url(uri_string()); ?"
var title =<?= $ video-> title;?>;
window.open('http://twitter.com/share?url= '+ loc +'& text ='+ title +'&','twitterwindow','height = 450,width = 550,top ='+($(window).height()/ 2 - 225)+ ',left ='+ $(window).width()/ 2 +',toolbar = 0,location = 0,menubar = 0,directories = 0,scrollbars = 0');
});

它可以正常使用网址和标题。问题是,我怎样才能分享一个图像呢?



非常感谢您的帮助。



更新:facebook中的参考
我可以分享像这样的内容,它也可以在twitter中完成吗?谢谢。



p>

解决方案

该图片来自您的HTML标记,当有人推文您的网址时,

Twitter是指将推文作为伴随的元信息的集合,他们在网络上出现之前需要批准。


  1. 仔细阅读 Twitter Cards Developer 页面

  2. 选择合适的卡片( summary_large_image 是个不错的卡片),并在您的HTML的头部

  3. 卡片验证程序
  4. 上验证您的卡片, a> page
  5. 将您的域名列入白名单后,任何带有您网址的推文也会包含您的名片


Here is the custom twitter icon code:

HTML:

<i id="twitter_share" class="fa fa-twitter fs20" style="position: relative; bottom: 4px;"></i>

And Jquery:

$('#twitter_share').click(function (e) {
    e.preventDefault();
    var loc = "<?= base_url(uri_string()); ?>";
    var title = "<?= $video->title; ?>";
    window.open('http://twitter.com/share?url=' + loc + '&text=' + title + '&', 'twitterwindow', 'height=450, width=550, top=' + ($(window).height() / 2 - 225) + ', left=' + $(window).width() / 2 + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');
});

It works fine with the url and title. The problem is , how can I share one image as well?

Thanks a lot for helping.

Update: reference in facebook in facebook I can share the content like this, can it be done in twitter as well? Thanks. !

解决方案

The image comes from your HTML markup, which is scraped by twitter when someone tweets your url.

Twitter refers to the collection of meta info accompanying a tweet as a card, which they need to approve before it will appear on the network.

  1. Have a good read through the Twitter Cards Developer page
  2. Select an appropriate card (summary_large_image is a good one) and include the appropriate twitter meta tags in the head of your HTML
  3. Validate your card on the Cards Validator page
  4. Once your domain has been whitelisted any tweets with your url will also include your card

这篇关于在自定义twitter分享图标中分享链接,标题和一个图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆