Giter Site home page Giter Site logo

kirby-qrcode's Introduction

Kirby QR Code

GitHub release License Kirby Version

Kirby CMS Panel Field and Page-Method rendering a QR Code.

Notes:

  • This plugin uses the endroid/QrCode lib v1.6.5.
  • This plugin does not cache the image but recreate it on every request and will save it to the /thumbs folder (kirby()->roots()->thumbs()).

Requirements

Installation

kirby plugin:install bnomei/kirby-qrcode

Git Submodule

$ git submodule add https://github.com/bnomei/kirby-qrcode.git site/plugins/kirby-qrcode

Copy and Paste

  1. Download the contents of this repository as ZIP-file.
  2. Rename the extracted folder to kirby-qrcode and copy it into the site/plugins/ directory in your Kirby project.

Usage

Field

Add a kirby panel field to your blueprint to show a qrcode of the kirby $page->url() within the panel. This plugin uses a global field definition to cut some corners. Default paramters of QR code lib will be used to render the image or the parameters set in your config.php.

#fieldname: fieldtype
qrcode: qrcode

Page Method

The plugin also adds a $page->qrcode() function which returns an image as Media object to use in templates etc.

You can use the default values, override them or set your own parameters on-the-fly using an associative array. Missing parameters will fallback to defaults of lib.

// DEFAULTS
$qrcodeDefault = $page->qrcode(); // Kirby Toolkit Media Object

// CUSTOM
$allCustomParameters = [
	'Text' => $page->url(), // plugin default
    'Size' => 300,
    'Padding' => 10,
    'ErrorCorrection' => 'high',
    'ForegroundColor' => ['r' => 0, 'g' => 0, 'b' => 255, 'a' => 0],
    'BackgroundColor' => ['r' => 255, 'g' => 255, 'b' => 255, 'a' =>0],
	'Label' => 'You take the blue pill',
    'LabelFontSize' => 16,
    'ImageType' => Endroid\QrCode\QrCode::IMAGE_TYPE_PNG,  // lib default
    'Filename' => $page->slug().'-qrcode', // plugin default
];

// override defaults. this can be done in config.php as well.
c::set('plugin.qrcode', $allCustomParameters);
$qrcodeCustom = $page->qrcode(); // using new defaults now

// or use them on-the-fly
$qrcodeCustom = $page->qrcode([
    'Label' => 'You take the red pill',
    'ForegroundColor' => ['r' => 255, 'g' => 0, 'b' => 0, 'a' => 0],
    'ImageType' => Endroid\QrCode\QrCode::IMAGE_TYPE_JPEG,
	]);

// then use media object to get brick and echo the image
// https://github.com/getkirby/toolkit/blob/master/lib/media.php#L539
echo $qrcodeCustom->html();

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.

kirby-qrcode's People

Contributors

bnomei avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.