Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlnchv committed Nov 25, 2018
0 parents commit d5e0b85
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
indent_style = space

[*.{yml,json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_size = 2
indent_style = space

[composer.json]
indent_size = 4
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Lazyloaded images for SilverStripe

## Introduction

This module implements the LQIP (Low Quality Image Placeholder) pattern (combined with a blur-up CSS transition) powered by [lazysizes](https://github.com/aFarkas/lazysizes).

## Requirements

* SilverStripe 4

## Installation

```bash
composer require dnadesign/silverstripe-lazyloaded-image
```

## Usage

```html
$Image.Lazyloaded
```
11 changes: 11 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
Name: lazyloadedimage
---

SilverStripe\Assets\Image:
extensions:
- DNADesign\LazyloadedImage\LazyloadedImageExtension

SilverStripe\Assets\Storage\DBFile:
extensions:
- DNADesign\LazyloadedImage\LazyloadedImageExtension
2 changes: 2 additions & 0 deletions client/javascript/lazysizes.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions client/javascript/ls.blur-up.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "dnadesign/silverstripe-lazyloaded-image",
"description": "Implements the LQIP (Low Quality Image Placeholder) pattern powered by lazysizes",
"type": "silverstripe-vendormodule",
"keywords": [
"silverstripe",
"lazyload",
"lazysizes",
"image"
],
"license": "MIT",
"require": {
"silverstripe/vendor-plugin": "^1.0",
"silverstripe/framework": "^4.0",
"chrometoaster/silverstripe-image-quality": "~1.0"
},
"autoload": {
"psr-4": {
"DNADesign\\LazyloadedImage\\": "src/"
}
},
"extra": {
"installer-name": "silverstripe-lazyloaded-image",
"expose": [
"client"
]
}
}
19 changes: 19 additions & 0 deletions src/LazyloadedImage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace DNADesign\LazyloadedImage;

use SilverStripe\Core\Extension;
use SilverStripe\View\Requirements;

class LazyloadedImageExtension extends Extension
{
public function getLazyloaded()
{
Requirements::javascript('dnadesign/silverstripe-lazyloaded-image:client/javascript/lazysizes.min.js');
Requirements::javascript('dnadesign/silverstripe-lazyloaded-image:client/javascript/ls.blur-up.min.js');

return $this->owner->customise([
'LQIP' => $this->owner->Quality(20)
])->renderWith('Includes/LazyloadedImage');
}
}
17 changes: 17 additions & 0 deletions src/templates/Includes/LazyloadedImage.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<style>
.blur-up {
filter: blur(5px);
transition: filter 400ms;
}

.blur-up.lazyloaded {
filter: blur(0);
}
</style>

<img
class="lazyload blur-up"
src="$LQIP.URL"
data-src="$URL.ATT"
alt="$Title.ATT"
/>

0 comments on commit d5e0b85

Please sign in to comment.