Skip to content

Instantly share code, notes, and snippets.

@supasympa
Created December 5, 2011 14:54
Show Gist options
  • Save supasympa/1433849 to your computer and use it in GitHub Desktop.
Save supasympa/1433849 to your computer and use it in GitHub Desktop.
Some code to update ShareThis buttons with custom images - useful in SPAs or AJAX apps
function updateShareButtons(location, title, imgsrc) {
$('.share').hide();
$('.sharethis').html('');
var services = [
{type : 'facebook',
image : './css/img/social-facebook.png'},
{type : 'twitter',
image : './css/img/social-twitter.png'},
{type : 'email',
image : './css/img/social-email.png'},
{type : 'sharethis',
image : './css/img/social-more.png'}
];
var svc, elm;
for (var i = 0; i < services.length; i++) {
svc = services[i];
elm = $(['<span class="st_',svc.type,'_custom" st_url="',location,'" st_title="',title,'" st_image="',imgsrc,'"><img src="',svc.image,'"/></span>'].join(''));
$('.sharethis').append(elm);
}
stButtons.locateElements();
$('.share').show();
}
@kmakarem
Copy link

kmakarem commented Dec 1, 2016

Simple and great code.

shareThis still did not implement an updateEntity fn so this is still effective.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment