2017 © Pedro Peláez
 

craft-plugin svgplaceholder

A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates.

image

mblode/svgplaceholder

A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates.

  • Thursday, December 14, 2017
  • by mblode
  • Repository
  • 1 Watchers
  • 6 Stars
  • 541 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 49 % Grown

The README.md

SVG Placeholder plugin for Craft CMS 3.x

A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates., (*1)

Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later., (*2)

Installation

To install the plugin, follow these instructions., (*3)

  1. Open your terminal and go to your Craft project:, (*4)

    cd /path/to/project
  2. Then tell Composer to load the plugin:, (*5)

    composer require mblode/svgplaceholder
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for svgplaceholder., (*6)

Usage

{{ craft.svgplaceholder.generate({height:500,width:'300'}) }}

Optionally add a background color with the fill attribute:, (*7)

{{ craft.svgplaceholder.generate({height:500,width:'300'},'#CCCCCC') }}

Example

When used with Lazysizes and a macro:, (*8)

_macros/utilities.html, (*9)

{% macro lazyLoadImage(element, transform) %}
        {% cache using key element.id %}
            <img class="lazyload" src="{{ craft.svgplaceholder.generate({ height: element.height(transform), width: element.width(transform) }) }}" data-src="{{ element.url(transform) }}" alt="{{ element.title }}">
        {% endcache %}
{% endmacro %}

index.html, (*10)

{% import '_macros/utilities' as utils %}

...

{{ utils.lazyLoadImage(image, 'imageTransformName') }}

Brought to you by Matthew Blode, (*11)

Based on the Craft CMS 2 plugin: SVG Placeholder, (*12)

The Versions

14/12 2017

dev-master

9999999-dev

A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates.

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft craft cms svgplaceholder craft plugin svg placeholder

14/12 2017

1.0.3

1.0.3.0

A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates.

  Sources   Download

MIT

The Requires

 

cms craft craft cms craft plugin svg placeholder

18/11 2017

1.0.1

1.0.1.0

A plugin which generates an invisible SVG of specific dimensions for use when lazyloading images in Craft CMS templates.

  Sources   Download

MIT

The Requires

 

cms craft craft cms craft plugin svg placeholder

08/09 2017

1.0.0

1.0.0.0

SVG Placeholder

  Sources   Download

MIT

The Requires

 

cms craftcms craft-plugin craft svgplaceholder