Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Created July 19, 2012 20:51
Show Gist options
  • Select an option

  • Save elijahmanor/3146729 to your computer and use it in GitHub Desktop.

Select an option

Save elijahmanor/3146729 to your computer and use it in GitHub Desktop.
jQuery qrLinkify Plugin: Add QR codes next to anchor links
/* jQuery qrLinkify Plugin: Add QR codes next to anchor links
* Author: @elijahmanor
* Example Usage:
* $( "a" ).qrLinkify();
* $( "a" ).qrLinkify({ width: 250, height: 250 });
*/
$.fn.qrLinkify = function( options ) {
options = $.extend( {}, $.fn.qrLinkify.defaults, options );
return this.each( function( index ) {
var $this = $( this ),
url = $this.attr( "href" );
$( "<img />", {
src: "https://chart.googleapis.com/chart?cht=qr&chl=" + escape( url ) + "&choe=UTF-8&chs=" + options.width + "x" + options.height
}).insertAfter( $this );
});
};
$.fn.qrLinkify.defaults = { width: 100, height: 100 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment