qrcodejs icon indicating copy to clipboard operation
qrcodejs copied to clipboard

Include Image in center in QR code

Open ashish20790 opened this issue 3 years ago • 1 comments

Hello, Is there a way that we can include some image in the center of generated QR code via qrcode.js.

ashish20790 avatar Jan 24 '22 15:01 ashish20790

A little workaround is to use jQuery to remove the display: block property from the img tag that holds the QRCode, this can be done after you've created the QRCode instance and the data is rendered to the target tag.

Example:

new QRCode(document.getElementById("qrCodeHolder"), "https://example.com/");
$("#qrCodeHolder").find("img").css("display", "");

EDIT: I'd suggest you delay the jQuery code by 500 ms or so, because there's a high chance that the QR code isn't rendered yet while jQuery is looking for the element. So better use a setTimeout().

XiXiongMaoXiong avatar Feb 04 '22 18:02 XiXiongMaoXiong