我正在使用addthis工具箱将我网站上的网页分享到社交媒体。这是我的全部内容:
<div class="print_share">
<ul>
<li>
<!-- addthis print button begin -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_print"><svg class="icon icon--print"><use xmlns:xlink="https://www.w3.org/1999/xlink" xlink:href="/images/icons/svg-sprite.svg#icon-print"></use></svg> Print</a>
</div>
<!-- addthis print button end-->
</li>
<li>
<!-- addthis email button begin -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_email"><svg class="icon icon--email"><use xmlns:xlink="https://www.w3.org/1999/xlink" xlink:href="/images/icons/svg-sprite.svg#icon-email"></use></svg> Email</a>
</div>
<!-- addthis email button end-->
</li>
<li>
<!-- addthis menu button begin -->
<div class="addthis_toolbox addthis_default_style" data-media="http://i.imgur.com/sI5mrZP.png">
<div class="share_interstitial" style="display: none">
<span class="at16nc at300bs at15nc at15t_compact at16t_compact"><span class="at_a11y">More Sharing Services</span></span>
<a>Share</a>
<div class="share_loading" style="display: none"><img height="50" src="/images/loading.gif"/><span>Generating thumbnail image...</span></div>
</div>
<a class="addthis_button_compact"><svg class="icon icon--share"><use xmlns:xlink="https://www.w3.org/1999/xlink" xlink:href="/images/icons/svg-sprite.svg#icon-share"></use></svg> Share</a>
</div>
<!-- addthis menu button end-->
</li>
<li><span>Hello</span></li>
</ul>
</div>
我也有这个脚本,我将$(document).ready()
方法添加到:
<script language="javascript" type="text/javascript">
var addthis_share = {
url_transforms: {
shorten: {
twitter: 'bitly'
}
},
shorteners: {
bitly: {}
},
media: "http://i.imgur.com/sI5mrZP.png"
};
var addthis_config = {
ui_click: true,
services_compact: 'facebook,twitter,more',
services_exclude: 'gmail,email,print,printfriendly,favorites,blogger,w3validator'
};
$(document).ready(function() {
console.log(addthis);
if (typeof addthis !== 'undefined') {
addthis.update('share', 'image', "http://i.imgur.com/sI5mrZP.png");
if (addthis_share.passthrough) {
addthis_share.passthrough.pinterest_share.media = "http://i.imgur.com/sI5mrZP.png";
}
addthis.toolbox('.addthis_toolbox', addthis_config, addthis_share);
}
});
</script>
但图像永远不会被包含在内。当我在data-media
元素上设置属性addthis_toolbox
时,为什么不共享图像?