PHP code example of accudio / php-plaiceholder
1. Go to this page and download the library: Download accudio/php-plaiceholder 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/ */
accudio / php-plaiceholder example snippets
$image_path = '/path/to/your/image.jpg';
$placeholder = new accudio\PHPPlaiceholder\PHPPlaiceholder($image_path);
$css_style = $placeholder->get_css();
// background-image: linear-gradient(...); background-position: 0 0,0 50%,0 100%;
// background-size:100% 33.33%; background-repeat:no-repeat;
$css_properties = $placeholder->get_css('properties');
// --plaice-image: linear-gradient(...); --plaice-position: 0 0,0 50%,0 100%;
// --plaice-size:100% 33.33%; --plaice-repeat:no-repeat;
$css_array = $placeholder->get_css('array');
// [
// 'background-image' => 'linear-gradient(...)',
// 'background-position' => '0 0,0 50%,0 100%',
// 'background-size' => '100% 33.33%',
// 'background-repeat' => 'no-repeat'
// ]
$svg_with_styles = $placeholder->get_svg();
// <svg xmlns="http://www.w3.org/2000/svg"
// style="
// position: absolute;
// top: 50%;
// left: 50%;
// transform-origin: top left;
// transform: translate(-50%, -50%);
// right: 0;
// bottom: 0"
// width="100%" height="100%"
// shaperendering="crispEdges" preserveAspectRatio="none"
// viewBox="0 0 4 3"
// >
// <rect fill="rgb(155,104,152)" fill-opacity="1" x="0" y="0" width="1" height="1">
// ...
// </svg>
$svg_no_styles = $placeholder->get_svg(false);
// <svg xmlns="http://www.w3.org/2000/svg"
// width="100%" height="100%"
// shaperendering="crispEdges" preserveAspectRatio="none"
// viewBox="0 0 4 3"
// >
// <rect fill="rgb(155,104,152)" fill-opacity="1" x="0" y="0" width="1" height="1">
// ...
// </svg>
$base64 = $placeholder->get_base64();
// data:image/jpeg;base64,...
$blurhash = $placeholder->get_blurhash();
// UqF}a5-WR*xw~E$+WBt8-DxHWBa$$-xHWBai
composer