-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d5e0b85
Showing
8 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
/> |