Placeholder Pixel plugin for Craft CMS 3.x
Create a base64-encoded transparent pixel of the given width and height, (*1)
Pixels once generated are cached on a width * height basis to reduce load, (*2)
Requirements
This plugin requires Craft CMS 3.0.0-RC1 or later., (*3)
Installation
To install the plugin, follow these instructions., (*4)
-
Open your terminal and go to your Craft project:, (*5)
cd /path/to/project
-
Then tell Composer to load the plugin:, (*6)
composer require tibemolde/placeholder-pixel
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for Placeholder Pixel., (*7)
Placeholder Pixel Overview
Create a base64-encoded transparent pixel of the given width and height, (*8)
Configuring Placeholder Pixel
No configuration is needed outside of runtime-options, (*9)
Using Placeholder Pixel
Base usage:, (*10)
craft.placeholderPixel.get(options)
Default options:, (*11)
{
width : 1,
height : 1,
aspectRatio : {
w: 16,
h: 10
}
}
Examples:, (*12)
-
1 x 1 pixel:, (*13)
<img src="{{ craft.placeholderPixel.get }}" alt="">
-
Pixel with two specific dimensions:, (*14)
<img src="{{ craft.placeholderPixel.get({width: 64, height: 64}) }}" alt="">
-
Pixel with one specific dimension and default aspect-ratio:, (*15)
<img src="{{ craft.placeholderPixel.get({width: 1024}) }}" alt="">
-
Pixel with one specific dimension and specific aspect-ratio:, (*16)
<img src="{{ craft.placeholderPixel.get({width: 1024, aspectRatio: {w: 5, h: 4}}) }}" alt="">
Placeholder Pixel Roadmap
Some things to do, and ideas for potential features:, (*17)
- Make it better, somehow? :o
Brought to you by TIBE Molde, (*18)