Endroid/Qrcode library with wordpress

Hello friends i have an issue with endroid/qrcode libarary i created custom page template and the function .getContentType(); return the link of the page, and insert it into the img src, instead return the path of the actual image path that was created, i will glad for some helps, and advice’s, thanks appreciate it so much 🙂
This is my code, out side of wordpress it works perfectly but when i put it in a custom page template or cpt template the function above return the wrong path..

include WP_CONTENT_DIR .'/endroid_qrcode/src/QrCode.php';

use EndroidQrCodeQrCode;

$qr = new QrCode();

->setLabel('Scan the code', 16, __DIR__.'/../font/open_sans.ttf')
->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0])
->setBackgroundColor(['r' => 240, 'g' => 230, 'b' => 255, 'a' => 0])
->setLabel('Scan Me For Info')


// save it to a file

// now we can directly output the qrcode

header('Content-Type: '.$qr->getContentType());

as u can see the img src is the link to the page instead the file path,
the file was created, but the src in the img tag is generated the wrong way, what am i doing wrong?

output in the browser

Read more here: Endroid/Qrcode library with wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *