Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Image in center in QR code #268

Open
ashish20790 opened this issue Jan 24, 2022 · 1 comment
Open

Include Image in center in QR code #268

ashish20790 opened this issue Jan 24, 2022 · 1 comment

Comments

@ashish20790
Copy link

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

@XiXiongMaoXiong
Copy link

XiXiongMaoXiong commented Feb 4, 2022

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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants