Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-03-31 21:35:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

smd_qr_code: embed Quick Response barcodes on your site

They’re small. They’re square. They’re everywhere.

Join the 2D barcode revolution and offer camera- and smart-phone visitors promotions, downloads, contact info, vouchers, geographical location, web links, bookmarks, or pretty much anything you can dream up. All in a small square of black-and-white binary data.

Download the plugin and let me know how it works for you.

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.

31 Mar 11 | 0.10 | Initial public release
02 Apr 11 | 0.20 | Added title attribute for the <img> tag ; added vcard type (thanks gomedia) ; added validate and validelim to allow regex overrides ; fixed url regex ; improved error reporting ; permitted debug to aid in tracking down regex / validation errors
04 Apr 11 | 0.30 | Wrote more flexible, custom interface to Google Charts API ; added layout, transform and prefix attributes ; improved validate attribute
05 Apr 11 | 0.31 | Double-quotes not single quotes for proper backslashing ; fixed callback warning when no plugin callbacks defined (both thanks gomedia)

Last edited by Bloke (2011-04-05 08:39:48)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2011-03-31 22:35:37

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 595
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

Wow, Stef. I have a client who’s looking for excuses to use these. Love that you can adjust the background color & transparency…just brainstorming here but you could quickly generate image overlay previews for forehead tattoos, maybe best to wait until 2012 for that tho.

Offline

#3 2011-03-31 23:28:52

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: smd_qr_code: embed Quick Response barcodes on your site

Hi Stef,

QR Codes were trumpeted as the “next big thing” in Australia but take-up has been half-hearted to say the least. We’ve put them on client’s promotional material but, other than Japanese tourists, I don’t think the general antipodean population knows what they are.

I’ve had one on my website (& business cards) for yonks but it’s in VCARD format – a bit like your MECARD but with a website address:

BEGIN:VCARD
FN:Great Ocean Media
EMAIL:info [at] greatoceanmedia [dot] com [dot] au
URL:www.greatoceanmedia.com.au
TEL:0439 484250
END:VCARD

(email address obfuscated to protect the guilty)

Is this format currently possible with smd_qr_code?

Offline

#4 2011-03-31 23:35:30

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

I use these all the time to send a website I’m at on my desktop to my Android phone (when I’m not using Chrome and the Chrome to Phone plugin).

Will browsers cache the google created barcode image or request it every time?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2011-04-01 06:36:52

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

heh. “download me… you know you want to.”

Offline

#6 2011-04-01 08:17:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: smd_qr_code: embed Quick Response barcodes on your site

maruchan

Glad you like it. Thank Google’s awesome charts API for the bg/alpha support. Before I started this plugin yesterday morning I looked into a proper PHP library with GD support and everything but it was about 250KB of download/install hassle. Then I stumbled upon the charts API and as well as cutting dev time by an order of magnitude and making usage a snap, it’s more flexible/extensible. Which brings me to…

gomedia wrote:

Is this format [VCARD] currently possible with smd_qr_code?

No, but it’s trivial to add. I had a half-notion that it might be useful to define your own formats but couldn’t figure out a neat way of doing so (yet). Maybe one day. In the meantime I’ll add vcard support today as well as enabling a ‘title’ attribute for the <img> tag, which is nice for offering instructions like ‘photograph me with your mobile camera, you doughnut’ to the uninitiated :-)

MattD

Not sure if browsers will cache the image. Certainly the plugin doesn’t offer cacheing at the moment. Perhaps it should. Let me look into it, thanks for the idea.

mrdale

Couldn’t resist :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2011-04-01 09:10:52

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

gomedia wrote:

QR Codes were trumpeted as the “next big thing” in Australia but take-up has been half-hearted to say the least. We’ve put them on client’s promotional material but, other than Japanese tourists, I don’t think the general antipodean population knows what they are.

Apparently Google is giving up on QR Codes. I kind of like them, but they’ve been under used and not widely understood.

Offline

#8 2011-04-01 11:30:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: smd_qr_code: embed Quick Response barcodes on your site

monkeyninja wrote:

Apparently Google is giving up on QR Codes

As long as their business decision to not support them in their Places accounts doesn’t mean they’ll ultimately remove the QR code generating ability from the Charts API, we’re in the clear. Very odd that they’d ditch them. Just because they can’t find a way to leverage them (believe me, we’ve tried to change their outlook on location-based advertising but they’re not interested in owning the market so we’ve gone elsewhere) hopefully won’t preclude others from finding a use for them.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2011-04-01 12:14:01

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

Bloke wrote:

As long as their business decision to not support them in their Places accounts doesn’t mean they’ll ultimately remove the QR code generating ability from the Charts API, we’re in the clear. Very odd that they’d ditch them. Just because they can’t find a way to leverage them (believe me, we’ve tried to change their outlook on location-based advertising but they’re not interested in owning the market so we’ve gone elsewhere) hopefully won’t preclude others from finding a use for them.

There are so many places that could make use of QR codes with the rise in smart phones, I’m surprised to not see them about the place more often. Print advertising could surely benefit from them.

Anyway, nice work with the plugin.

Offline

#10 2011-04-01 16:55:41

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_qr_code: embed Quick Response barcodes on your site

It looks to me like the image is cachable for 24 hours.

Expires: Sat, 02 Apr 2011 16:52:57 GMT  
Cache-Control: public, max-age=86400

My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#11 2011-04-01 17:39:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: smd_qr_code: embed Quick Response barcodes on your site

MattD wrote:

It looks to me like the image is cachable for 24 hours.

Hmm, well if it is, the plugin isn’t honouring it so I need to rethink how it’s done. At the moment it always inserts the URL to the charts API inside the <img> tag’s src attribute which means it goes to the server every time. I haven’t studied the traffic yet but certainly Firebug’s Net pane confirms that a request is going to Google every page refresh. Whether Google returns some kind of Not-modified header or if the browser catches it and serves the local image I don’t know yet.

In the meantime I’ve been toying with manual (plugin) cacheing today and it’s almost working. Since I can’t rely on allow_url_fopen I can’t just see if site.com/images/smd_qr_codes/cached_file exists and serve it from there. Shame :-(

So I’ve elected to store the image data (base64 encoded) in the cache directory and then, if the file exists and you’ve chosen to use the cache (it’s on by default) it serves it as src="data:image/png;base64,file_contents_here". It’s doing it and it technically looks ok, but it’s not rendering the image in the browser for some reason. And this precludes <IE7 from the mix, but I don’t very much care.

I’m sure I’ll figure it out but the simplest solution by far would be if I could render something in the src attribute that the browser could figure was identical and serve the cached copy. If anyone can confirm or deny what’s going on between the server and the browser here I’d be very grateful. Saves me getting Wireshark out and might save me a lot of code if it’s already cacheing it.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2011-04-01 17:45:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: smd_qr_code: embed Quick Response barcodes on your site

Wait, maybe it is cacheing it already. W00t! That saves me some headaches. Anyone confirm this?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB