horst

Module
Pia - Pageimage Assistant

45 posts in this topic

Pia - Pageimage Assistant

Hello, today I can tell you that Pia Ballerina want to assist you with Pageimages   pia-ballerina_titel.jpg
and that can become really helpful! :)
.
.
.
Pia, in its current state, version 1.0.0, provides:

  • a GUI (the module config screen) for quick and easy changes to the sitewide Pageimage default options
     
  • an alternative way for calling the Pageimage resizing methods with PW selector strings
     
  • three new methods as shortcuts to the resizing functions
     
  • a new method called retinafy and its alias hiDPI, (introduced in version 0.2.0)

.
.
.
2) Instead of ->width(), ->height(), ->size() you can call ->pia() now. With a PW selector string you tell Pia what image variation you want to have :
.

$image->pia("width=100, quality=80, sharpening=medium")->url;

.
If you want process ->width() just define width.
If you want process ->height() only define height.
If you want process ->size() just define width and height.
If you want process ->size() with equal values for width and height, just define only size, or use the alias square:
.

$image->pia("width=480")->url;
$image->pia("height=320")->url;
$image->pia("width=400, height=300")->url;
$image->pia("size=350")->url;
$image->pia("square=350")->url;

.
So, yes, - I see. Now you may think: "Ok, nice looking girl, - and she can dance very well, - but for what should it be good that she is involved here? My very old buddies width, height and size - and me, - we don't need any Ballerinas between us!"
.
Yeah, I see what you mean. But this above is not what Pia is good for, this is just a little warming up for you. :)
.
In some cases one need to specify more than just width and / or height. If it comes to that you need explicitly populated options with the individual pageimages, Pia will become faster and more comfortable at some point. Also the code is looking more readable with Pia, at least to me:
.

// regular style #1:

$image->width(800, array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong"));

// or regular style #2:

$options = array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong");
$image->width(800, $options);

// now lets Pia dance:

$image->pia('width=800, upscaling=0, cropping=1, quality=80, sharpening=strong');

$image->pia('width=800, upscaling=off, cropping=on, quality=80, sharpening=strong');

.
For me it is that not only Pia begin to dance, my fingers do so too when writing selector strings instead of the regular array code. :)
.  
Ok, last thing before we can go to stage: "You already may have noticed that Pia accepts few different values for boolean expression, yes?"

  • for TRUE you can write these strings: "1, on, ON, true, TRUE, -1"
  • for FALSE you may use one out of "0, off, OFF, false, FALSE"

Ready? Ok, lets go to stage.
.
.
.
3) Pia provide three new methods as shortcuts. This means that when using one of the shortcuts you have pre-populated options, regardless of the sitewide default settings:

  • crop :: does what the name says
     
  • contain :: is equal to the regular method: ->size($width, $height, array("cropping" => false))
     
  • cover :: this, Pias third child, is a new kid on the block :)

.
Let's have a closer look and compare it. We use Pias image from above as source for this example. (It's dimensions are 289 x 400 px)
.
.
* crop

$image->crop('square=100'); 

.
pia-ballerina_titel.100x100-piacrop.jpg    it is 100 x 100 px    and the name is:  pia-ballerina_titel.100x100-piacrop.jpg
.
.
.
* contain

$image->contain('square=100');

.
pia-ballerina_titel.100x100-piacontain.j    it is 73 x 100 px   and the name is:  pia-ballerina_titel.100x100-piacontain.jpg
.
.
.
* cover

$image->cover('square=100'); 

.
pia-ballerina_titel.100x139-piacover.jpg    it is 100 x 139 px   and the name is:  pia-ballerina_titel.100x139-piacover.jpg
.
.
.
Ok, you got it?
.
"Crop" crop out the area, "Contain" fits the image into the area, and "Cover" calculates the needed dimensions for the image so that the area is completly covered by it.
.
Following is a link with lots of those crop-, contain-, cover- variations. I have stress-tested it a bit: much variations
.
----------
.
.
Later Additions:
.
* contain with option weighten
Since version 0.0.6 contain can take an additional param called "weighten". (read more here)
.
.
.

* retinafy
Since version 0.2.0 retinafy is added. It returns a markup string, e.g. a HTML img tag, where placeholders are populated with property values from the pageimage. Default properties are: URL, WIDTH, HEIGHT, DESCRIPTION. The method also can take an optional array with CustomPropertyNames. You also can use the alias HiDPI if you like. (read more here)

.
.
----------
.
.
You can get the module from the modules directory or from the repo on Github:
.

git clone https://github.com/horst-n/PageimageAssistant.git your/path/site/modules/PageimageAssistant

.
.
Bye! 
.

 

pia-ballerina_outro.jpg

Classical ballet performance at the Aalto Theatre in Essen, in the context of the Red Dot Award ceremony 26 June 2007,
Act III, Sleeping Beauty, the wedding reception
Photos: Horst Nogajski - www.nogajski.de

 

34 people like this

Share this post


Link to post
Share on other sites

It is incredible how it is in this PW forum, You go to sleep, you wake up, turn the computer on, and you find another jewel! It is all around the globe so magic just never stops! It is like a new year every day with presents under the tree. Thank you, mr. Horst!

And something on the substance:

1) It would be usefull in many cases (at least for me) to have a 4th method, which would act like contain, but would fill with adjustable color spaces to the left and right (or to the up and down if it is horisontal) making the thumb a squre, but still containing the whole of the image. Like this:

post-2275-0-94617800-1416728404.jpg

2) Could you please write a bit about how you work with images. We now have options from you: pim and pia (not forgetting about core methods). How do they work together? Should we use both or just one of them and in what cases?

2 people like this

Share this post


Link to post
Share on other sites

It is incredible how it is in this PW forum, You go to sleep, you wake up, turn the computer on, and you find another jewel! It is all around the globe so magic just never stops! It is like a new year every day with presents under the tree. Thank you, mr. Horst!

So true.  :rolleyes: Thanks horst. Pia is one fine lady.

1 person likes this

Share this post


Link to post
Share on other sites

1) It would be usefull in many cases (at least for me) to have a 4th method, which would act like contain, but would fill with adjustable color spaces to the left and right (or to the up and down if it is horisontal) making the thumb a squre, but still containing the whole of the image. Like this:

2) Could you please write a bit about how you work with images. We now have options from you: pim and pia (not forgetting about core methods). How do they work together? Should we use both or just one of them and in what cases?

thanks for the nice words.

1) unfortunately Pia only assist with preparing and delegating values to the images engines. She isn't able to process images her self.

What you are requesting is "canvas", it is provided by Pim. I don't know yet if Pia dynamically should support shortcuts depending on other installed modules or not. It can become a bit confusing. On the other hand I see how comfortable it could be if Pia would assist here too.

2) I will do so when finding a bit time for it.

So true.  :rolleyes: Thanks horst. Pia is one fine lady.

yes, she is! 

pia--one-fine-lady.jpg

2 people like this

Share this post


Link to post
Share on other sites

Updated to version 4

- I had to fix the forceNew option what may be used during site develope.

- also have changed a bit on the GUI: it detects if you have Fieldtype RangeSlider installed and uses that over a regular Integer Inputfield for Quality-Setting

If you are already using it, please update too.

Edited by horst
added change to version 4
2 people like this

Share this post


Link to post
Share on other sites

Hey horst - looks awesome, but I am running php 5.3.28 on my dev server (just to pick up on things like this) and get a parse error due to:

InputfieldRangeSlider::getModuleInfo()['version'] on line 345

Something like this takes care of it:

if($modules->isInstalled('InputfieldRangeSlider')) $rangeSliderInfo = InputfieldRangeSlider::getModuleInfo();
$hasSlider = $modules->isInstalled('InputfieldRangeSlider') && version_compare($rangeSliderInfo['version'], '1.0.4', '>=');
One minor typo while I think of it:
here you can set sitewide options, - this overrides the options from site/config.php
 
This is under the main config and also the advances section. As well as the missing "s", probably also don't need the comma and the hyphen.
2 people like this

Share this post


Link to post
Share on other sites

@Adrian: thanks for the feedback. Here she is a bit to modern I believe. I will change this soon! ^-^

5 people like this

Share this post


Link to post
Share on other sites

Hi Horst,

Many times I need to output a lot of logo's. Those logo's need to have the same visual weight. Some logo's need to be wider others need to be higher. May I purpose a new method 'logo' or something ?

Pia is dancing nicely with crop contain and cover, but could you let her swing with logo ?

I have a starting point here that works great (used it many times)

3 people like this

Share this post


Link to post
Share on other sites

Hi Martijn,

you mean you have a module that outputs images of different aspect ratios in a visual weighted manner?

This would be nice to have, once we have discussed on that already.

Regarding the name 'logo' I'm not sure. Can we find a more descriptive one?

visualWeighted is to long, :lol:

1 person likes this

Share this post


Link to post
Share on other sites

Yep that is what it does and yes that's a bad name. Logo was just a name to explain the method the best I guess.

1 person likes this

Share this post


Link to post
Share on other sites

New addition to contain: weighten!
 
If you want to put some images of different aspect ratio onto a webpage and you want that they are displayed more equal visual weightened, you can use this method and options now:
.
* contain with option weighten

$image->contain('square=90, weighten=on');

.
.
There is also the possibility to prioritize portrait or landscape oriented images:
.

$image->contain('square=90, weighten=x1');  // landscapes are a bit larger than portraits

$image->contain('square=90, weighten=x2');  // landscapes are a bit more larger than portraits

$image->contain('square=90, weighten=y1');  // portraits are a bit larger than landscapes 

$image->contain('square=90, weighten=y2');  // portraits are a bit more larger than landscapes 

.
.
Have a look to this output here:
.
pia_weighten_overview.jpg
.
.
.
.
PS:
@Martijn: I have taken your code for the calculations and set the percent value hard coded to 38. This way we only need to turn weighten on or off and have not to deal with values here. The only thing I have added to the calculation is an adjustment to fit better with the largest dimension into the initial bounding box dimensions. (Github)

7 people like this

Share this post


Link to post
Share on other sites

Big thanks Horst

 

The only thing I have added to the calculation is an adjustment to fit better with the largest dimension into the initial bounding box dimensions. (Github)

 

Thats why I used a rectangular box in the Gist to control it.

1 person likes this

Share this post


Link to post
Share on other sites

Thats why I used a rectangular box in the Gist to control it.

Yes, I know and I have used it initially that way. And you also can do it now: when passing width and height instead of square, the other possible options are ignored and the result should be similar to what you have got with the gist code, but maybe a bit larger. (20%)

I thought it would be easier and less confusion for average users to just have a switch for on/off and if they define a square of 120 that they get back the largest possible image with 120px.

If you also like / need the comp param dynamically to define, it can be easily added as a 'silent' option. :)

1 person likes this

Share this post


Link to post
Share on other sites
If you also like / need the comp param dynamically to define, it can be easily added as a 'silent' option. :)
 

Great ! :-) 

Share this post


Link to post
Share on other sites

I have updated the module to Version 0.1.0 beta and it has a new addition to the weighten option that can be used together with contain.
 
The initial code I have taken for weighten calculations is from Martijn. I have changed it to simplify its usage so that you only need to specify a bounding square and have to switch it on, or additionaly prioritize landscape oriented images in two favours: x1, x2 or do the same for portrait oriented images with: y1, y2. (read more in the posts above)
 
But if you (@Martijn ;) ) like to use more different options, like with the original ImageFitBoundaries.module, you can use it by specifying different values for width and height together with the new value "comp##". For ## you set the value for compression like comp20, comp30, comp40 or whatever you like.

:)

6 people like this

Share this post


Link to post
Share on other sites

But if you (@Martijn ;) ) like to use more different options, like with the original ImageFitBoundaries.module, you can use it by specifying different values for width and height together with the new value "comp##". For ## you set the value for compression like comp20, comp30, comp40 or whatever you like.

Don't know if it is already in. But I used ImageFitBoundaries with a 'double' loop. Let me explane :-)

- looping several images through the Module and get the widest value. (No images are scaled, only values are returned)

- then I search the widest image, and take the percentage it is compaired to the box.

- I use that percentage to scale all images up.

1 person likes this

Share this post


Link to post
Share on other sites

Don't know if it is already in. But I used ImageFitBoundaries with a 'double' loop. Let me explane :-)

- looping several images through the Module and get the widest value. (No images are scaled, only values are returned)

- then I search the widest image, and take the percentage it is compaired to the box.

- I use that percentage to scale all images up.

No, it isn't in like you explained here, but it is somehow in without a double loop. But only when using a square boundary box and when the images are between the ratio aspects 1:2 -> 2:1. Images with more extreme ratio aspects are scaled none linear so that those are displayed smaller.

So, the normal usage of weighten works like your description but is assuming the ratio aspect isn't wider than 2:1 / 1:2.

When we add an additional param for the widest aspect ratio we should get the same effect as you described, I think.

You first have to run a loop through the images, fetching their aspect ratios, and afterwards pass the highest value to the contain-weighten call.

With images == photgraphs I think the average usage is well covered the way how it is setup now. But with logos it could be go much further with aspect ratios. Maybe you can drop in a small list of real logo usage aspect ratios (with extremes), so that I get a grasp of what we are talking here?

1 person likes this

Share this post


Link to post
Share on other sites

I've used the 'double loop' in pluimveeweb on the right side with the "Kennispartners" logo's. Now there's only 1 partner but when there are 3 or more (2 logo's always visible) it'll get to the widest value possible for the widest logo. 336px / 2 = 168px.

Here's some example code that will explain it better.

$compress = 40; // heavier images compress more
$x = 400; // box size, reference for image
$y = 280; // box size, reference for image
$max = 0; // calculation of the widests image, used to scale all others.

// calculate max width all images ( settings as wide as possible )
foreach($partners as $partner) {
    $image = $partner->generic_logo;
    if($image instanceof Pageimage) {
        $box = $modules->get("ImageFitBoundaries");
        $info = $box->load($image, $x, $y, $compress)->info();
        $max = $max < $info['width'] ? $info['width'] : $max;
    }
}

$percent = 168 * 100 / $max; // 2 X 168 = 336px width of the column

foreach($partners as $partner) {
    $image = $partner->generic_logo;
    
    if($image instanceof Pageimage) {
    
        $box = $modules->get("ImageFitBoundaries");
        $info = $box->load($image, $x, $y, $compress)->info();
        $width = (int) round($info['width'] / 100 * $percent);
        $height = (int) round($info['height'] / 100 * $percent);

        $options = array(
            'quality' => 100,
            'sharpening' => 'none'
        );

        $thumb = $image->size($width, $height, $options);
    }
}

I'm really happy how much you've implemented so far and I think you should not over complicate the module. I think you should leave it how it is now.

Thanks again for implementing weighten !

1 person likes this

Share this post


Link to post
Share on other sites

Thanks for giving those insights. I have made a note to the additional param for wider aspect ratios, what wouldn't be much work to implement, but will wait if other users request support for weighten with those wider aspect ratios.

Thanks for your help with this. :)

1 person likes this

Share this post


Link to post
Share on other sites

New addition: retinafy!

this was created on request from @jjozsi here in this post.
.
* retinafy

// create a pageimage with any method you like
$image = $page->images->first()->size(400, 300);  

// call retinafy on it
echo $image->retinafy();

// it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage
<img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" alt="description" />

.
.
The default markup template has the default replacements URL, WIDTH, HEIGHT and DESCRIPTION.

<img src="[URL]" width="[WIDTH]" height="[HEIGHT]" alt="[DESCRIPTION]" />

You can change that to any markup you like in the modules Configpage!

.
.
If you have additional properties populated with pageimages in your system, you can provide an array with those property names:

// if you need custom properties in your markup, define the template in the modules config page with those placeholders, 
// please only use UPPERCASE and wrapp these [ ] around them
<img src="[URL]" width="[WIDTH]" height="[HEIGHT]" data-custom1="[CUSTOM1]" data-custom2="[CUSTOM2]" />

// call retinafy with custom property names
$customPropertyNames = array("custom1", "custom2");
echo $image->retinafy($customPropertyNames);

// it outputs a markup string like this, where width and height is populated with half the sizes of the pageimage
<img src="/site/assets/files/1234/basename.400x300.jpg" width="200" height="150" data-custom1="custom-value-1" data-custom2="custom-value-2" />

.
.

Regarding to the technique described in the article @jjozsi linked to in his post it would make much sense to use a low quality setting sitewide by defining it in the ImageSizerOptions, also available on the Pia Configpage. Otherwise, if this is not possible, you need to call your images for that you want the retinafy markup with the quality option set:

// create a pageimage with any method you like
echo $page->images->first()->size(400, 300, array("quality"=>35))->retinafy(); 
Edited by horst
5 people like this

Share this post


Link to post
Share on other sites

Hi Horst,

I've used weighten in a newsletter tool for company logo's and it working great. Thanks again for implementing it !

2 people like this

Share this post


Link to post
Share on other sites

Have updated Pia to 0.2.2 because she also was affected by the same issue as CroppableImage. Recent PW versions now (can) log modules API actions into logfile modules.txt. This is suppressed now. If you use Pia and a recent PW dev version, please update to 0.2.2. http://modules.processwire.com/modules/pageimage-assistant/

2 people like this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By psy
      ProcessWire DropboxAPI on GitHub: https://github.com/clipmagic/DropboxAPI
       
      This module is a wrapper for Kunal Varma's Dropbox PHP SDK https://github.com/kunalvarma05/dropbox-php-sdk
      It was created to perform a specific function for a client, ie upload PDF files on a PW website to a specific Dropbox account folder.
      The PDF files, created using @Wanze's excellent PagesToPdf module using the WirePDF functions, are generated from Formbuilder forms completed by front-end site visitors.  Works a treat!
      There's more that could be done to allow ProcessWire to take advantage of all the features of the SDK, eg downloads, multiple Dropbox accounts, etc. You are welcome to request changes and/or fork the GitHub project to extend the feature set.
      Enjoy!
      System requirements
      PHP 5.6.4 or greater Composer The PHP mbstring extension General information
      This module enables you to access a single Dropbox (www.dropbox.com) account to upload files from a ProcessWire website.
      All kudos to (https://github.com/kunalvarma05/dropbox-php-sdk) for the PHP API.
      First steps
      Visit (https://www.dropbox.com/developers) and read the documentation. Log into Dropbox and create a new application. It's recommended to limit ProcessWire App access to a specified folder Make a note of the App key, the App secret and the name of the Dropbox folder Installation
      Download the zip file into your site/modules folder then expand the zip file. Next, login to ProcessWire > go to Modules > click "Refresh". You should see a note that a new module was found. Install the DropboxAPI module. Configure the module with your App key, App secret and your Call Back URL You need to generate a Dropbox access token to enable your site to communicate with the nominated Dropbox account. Dropbox will generate a token for you or you can create a page for the front end of your ProcessWire site with a template to submit the token request to Dropbox, eg:
      <?php namespace ProcessWire; $drop = $modules->get('DropboxAPI'); if ($input->get->code && $input->get->state) { $code = $sanitizer->text($input->get->code); $state = $sanitizer->text($input->get->state); //Fetch the AccessToken $accessToken = $drop->getAccessToken($code, $state); echo "Copy/paste this code into the module configuration: " . $accessToken; } else { echo "<p><a href='" . $drop->getAuthURL() . "'>Log in with Dropbox</a></p>"; } ?> Once you have entered the token in the module configuration, you can unpublish this page.
      Usage
      Read the dropbox-php-sdk documentation!
      An example template for sending a file to a Dropbox App folder from ProcessWire:
      <?php namespace ProcessWire; use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; // send pdf to Dropbox $drop = $modules->get('DropboxAPI'); $app = new DropboxApp($drop->app_key, $drop->app_secret, $drop->authorization_code); if ($app) { //Configure Dropbox service $dropbox = new Dropbox($app); $dropboxFile = new DropboxFile('/path/to/myfilename.pdf'); $file = $dropbox->upload($dropboxFile, "/myfilename.pdf", ['autorename' => true]); //Uploaded File meta data if ($file) { $success = $file->getName() . " uploaded to Dropbox"; $drop->log($success); } }  
       
    • By sirhc
      Hi all,
      Im trying to install this core module and got the error of not having the ImageMagick library installed.
      But if im checking for the version of my ImageMagick installed on my server via SSH im getting this response;
      identify -version
      Version: ImageMagick 6.9.4-9 Q16 i386 2016-06-21 http://www.imagemagick.org
      Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
      License: http://www.imagemagick.org/script/license.php
      Features: Cipher DPC 
      Delegates (built-in): bzlib freetype gslib jng jpeg png ps tiff xml zlib
      Does this even mean the library is installed? And if yes, why cant i install my module?
      Pleaassee help me
      Greetz.
    • By kixe
      FieldtypeColor is on github

      Fieldtype stores a 32bit integer value reflecting a RGBA value.
      Input
      5 types of Inputfields provided
      Html5 Inputfield of type='color' (if supported by browser)    Inputfield type='text' expecting a 24bit hexcode string (RGB). Input format: '#4496dd'.
      The background color of the input field shows selected color Inputfield of type='text' expecting 32bit hexcode strings (RGB + alpha channel) Input format: '#fa4496dd' Inputfield with Spectrum Color Picker
      (Options modifiable) Inputfield type='text' with custom JavaScript and/or CSS (since version 1.0.3) Output
      Define output format under 'Details' tab in field settings. Select from the following 8 options
      string 6-digit hex color. Example: '#4496dd' string 8-digit hex color (limited browser support).  Example: '#fa4496dd' string CSS color value RGB. Example: 'rgb(68, 100, 221)' string CSS color value RGB. Example: 'rgba(68, 100, 221, 0.98)' string CSS color value RGB. Example: 'hsl(227, 69.2%, 56.7%)' string CSS color value RGB. Example: 'hsla(227, 69.2%, 56.7%, 0.98)' string 32bit raw hex value. Example: 'fa4496dd' int 32bit. Example: '4198799069' (unformatted storage value) The Fieldtype includes
      Spectrum Color Picker by Brian Grinstead

      SCREENSHOTS
      Input type=text with changing background and font color (for better contrast)

      Input type=color (in Firefox)


      Javascript based input (Spectrum Color Picker)


      Settings Output

       
      Settings Input

    • By zlitrox
      Hi!
      I'm relatively new to the world of Processwire, but so far I'm really impressed by this CMS and its ease, power and speed.
      I've been looking at the different field types and also existing CKEditor modules (pwimage and pwlink).
      Here's what i want to achieve:
      I would like to use or create a own module which allows my admin users to upload pdf files inline in a CKEditor field (page content) the same way images are handled. It should be possible to upload a pdf file and specify its name and from the file uploaded and name i want to show an icon or image inline in editor and the output for that upload should be customized based on the module. Lets make it simple and say that i upload datasheet-1.pdf and want it to be named "My product datasheet", i want the output to be:
      <a href="{ link to uploaded pdf file }">My product datasheet</a>  
      Also the uploaded pdf files should be related to the page the user is editing.
       
      Is this doable? 
       
      Any guidance would be greatly appreciated! Thanks in advance.
      PS. I'm a PHP programmer so i know it would require some custom code, but the real question is where do i start, what should it take and is it even possible to do?
    • By flydev
      Auth2Login for ProcessWire
      A Module which give you ability to login an existing user using your favorite thrid-party OAuth2 provider (i.e. Facebook, GitHub, Google, LinkedIn, etc.)..
      You can login from the backend to the backend directly or render a form on the frontend and redirect the user to a choosen page.
      Built on top of ThePhpLeague OAuth2-Client lib.
      Registration is not handled by this module but planned.
       
      Howto Install
      Install the module following this procedure:
       - http://modules.processwire.com/modules/oauth2-login/
       - https://github.com/flydev-fr/OAuth2Login
      Next step, in order to use a provider, you need to use Composer to install each provider
      ie: to install Google, open a terminal, go to your root directory of pw and type the following command-line: composer require league/oauth2-google
      Tested providers/packages :
          Google :  league/oauth2-google     Facebook: league/oauth2-facebook     Github: league/oauth2-github     LinkedIn: league/oauth2-linkedin
      More third-party providers are available there. You should be able to add a provider by simply adding it to the JSON config file.

      Howto Use It
      First (and for testing purpose), you should create a new user in ProcessWire that reflect your real OAuth2 account information. The important informations are, Last Name, First Name and Email. The module will compare existing users by firstname, lastname and email; If the user match the informations, then he is logged in.
      ie, if my Google fullname is John Wick, then in ProcessWire, I create a new user  Wick-John  with email  johnwick@mydomain.com
      Next step, go to your favorite provider and create an app in order to get the ClientId and ClientSecret keys. Ask on the forum if you have difficulties getting there.
      Once you got the keys for a provider, just paste it into the module settings and save it. One or more button should appear bellow the standard login form.
      The final step is to make your JSON configuration file.
      In this sample, the JSON config include all tested providers, you can of course edit it to suit your needs :
      { "providers": { "google": { "className": "Google", "packageName": "league/oauth2-google", "helpUrl": "https://console.developers.google.com/apis/credentials" }, "facebook": { "className": "Facebook", "packageName": "league/oauth2-facebook", "helpUrl": "https://developers.facebook.com/apps/", "options": { "graphApiVersion": "v2.10", "scope": "email" } }, "github": { "className": "Github", "packageName": "league/oauth2-github", "helpUrl": "https://github.com/settings/developers", "options": { "scope": "user:email" } }, "linkedin": { "className": "LinkedIn", "packageName": "league/oauth2-linkedin", "helpUrl": "https://www.linkedin.com/secure/developer" } } }  
      Backend Usage
      In ready.php, call the module :
      if($page->template == 'admin') { $oauth2mod = $modules->get('Oauth2Login'); if($oauth2mod) $oauth2mod->hookBackend(); }  
      Frontend Usage
      Small note: At this moment the render method is pretty simple. It output a InputfieldForm with InputfieldSubmit(s) into wrapped in a ul:li tag. Feedbacks and ideas welcome!
      For the following example, I created a page login and a template login which contain the following code :
      <?php namespace ProcessWire; if(!$user->isLoggedin()) { $options = array( 'buttonClass' => 'my_button_class', 'buttonValue' => 'Login with {provider}', // {{provider}} keyword 'prependMarkup' => '<div class="wrapper">', 'appendMarkup' => '</div>' ); $redirectUri = str_lreplace('//', '/', $config->urls->httpRoot . $page->url); $content = $modules->get('Oauth2Login')->config( array( 'redirect_uri' => $redirectUri, 'success_uri' => $page->url ) )->render($options); }

       
      Screenshot