PHP code example of daun / processwire-image-placeholders
1. Go to this page and download the library: Download daun/processwire-image-placeholders library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daun / processwire-image-placeholders example snippets
$page->image->lqip; // data:image/png;base64,R0lGODlhEAAQAMQAA
$page->image->lqip(300, 200); // 300x200px
wire()->addHookAfter('ImagePlaceholders::getPlaceholderDataUri', function (HookEvent $e) {
$image = $e->arguments('image');
if ($image->ext === 'png' || $image->ext === 'gif') {
$e->return = '';
}
});
html
<!-- Using the placeholder as src while lazyloading the image -->
<img
src="<?= $page->image->lqip