在自定义twitter分享图标中分享链接,标题和一个图片 [英] Share the link , title and one image in custom twitter share icon
问题描述
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是指将推文作为卡伴随的元信息的集合,他们在网络上出现之前需要批准。
- 仔细阅读 Twitter Cards Developer 页面
- 选择合适的卡片( summary_large_image 是个不错的卡片),并在您的HTML的头部
- 在卡片验证程序 上验证您的卡片, a> page
- 将您的域名列入白名单后,任何带有您网址的推文也会包含您的名片
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.
- Have a good read through the Twitter Cards Developer page
- Select an appropriate card (summary_large_image is a good one) and include the appropriate twitter meta tags in the head of your HTML
- Validate your card on the Cards Validator page
- Once your domain has been whitelisted any tweets with your url will also include your card
这篇关于在自定义twitter分享图标中分享链接,标题和一个图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!