2. July 2013
von Blackbam

Recently a client wanted to display social media buttons like facebook, twitter and google plus at the bottom of each image in jQuery Colorbox. As it is bad practice to change the source code of a Plugin, the following code worked well for this job.

 

Note: This client wanted the full URL to be liked, not the image itself - if you want to do so, you should  like/recommend the attachemnt URL of the colorbox images, not the URL of the page. I will leave this up to you, to change the code in this way.

 

Add the following jQuery code to the footer of your page:

  jQuery(document).ready(function() {
   var facebook = '<div class="cb_social_elem cb_fb"><div class="fb-like" data-href="" data-send="false" data-layout="button_count" data-width="160" data-show-faces="true" data-font="arial"></div></div>';
   var twitter = '<div class="cb_social_elem"><a href="https://twitter.com/share" class="twitter-share-button" data-lang="de" data-count="horizontal">Tweet</a></div>';
   var google = '<div class="cb_social_elem"><g:plusone size="medium" annotation="bubble"></g:plusone></div>';
   
      jQuery("#cboxContent").append('<div id="cboxSocials">'+facebook+twitter+google+'</div><div class="clear"></div>');
  });
CSS code
#cboxSocials {
 margin-top:-43px;
}

.cb_social_elem {
 float:left;
 margin-right:20px;
 width:120px;
}

 

Social Buttons Developer Links

Facebook Like

Twitter

Google+

LinkedIn

Pinterest

Share

Dieser Eintrag wurde am 2. July 2013 um 15:15 in der Kategorie jQuery veröffentlicht. You can book the comments for this article RSS 2.0. Feedback, discussion, commendation and critics are welcome: Write a comment or trackback.


Tags: , ,

Already 12 comments belonging to "How to add social media buttons to jQuery Colorbox":

Kommentare abonnieren (RSS) or URL Trackback

peter ames   says:

on 09. October 2013 at 20:17 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 09. October 2013 at 23:17 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 17. November 2013 at 16:09 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 08. January 2014 at 20:59 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 10. January 2014 at 19:34 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 16. January 2014 at 21:45 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 01. April 2014 at 16:26 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 02. April 2014 at 19:19 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 25. May 2014 at 11:05 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 03. October 2014 at 17:04 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 04. October 2014 at 16:50 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

peter ames   says:

on 19. October 2014 at 20:33 on clock


Great script! Thanks! Any idea how I'd actually make it able to like the image and not the entire page?

Leave a comment: