Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit fe9e081

Browse files
committed
Documentation.
1 parent 362ff1c commit fe9e081

File tree

5 files changed

+39
-11
lines changed

5 files changed

+39
-11
lines changed

assets/js/dist/imageset.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,8 @@
13361336

13371337
debouncedCheckImagesets();
13381338
} else {
1339-
checkImagesets();
1339+
// If autoUpdate is disabled, check imagesets just once.
1340+
ready(checkImagesets);
13401341
}
13411342

13421343
return {

assets/js/dist/imageset.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/src/imageset.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,8 @@
740740

741741
debouncedCheckImagesets();
742742
} else {
743-
checkImagesets();
743+
// If autoUpdate is disabled, check imagesets just once.
744+
ready(checkImagesets);
744745
}
745746

746747
return {

changelog.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# ImageSet Changelog
22

3-
- unversioned
4-
- Fix mosaic placeholder rendering rendered too small.
3+
- `1.1.0-beta1` (2017/09/08)
4+
- [Fix] Fix mosaic placeholder rendering rendered too small.
5+
- [Fix] Remove double-loading settings from config
6+
- [Feature] Add JavaScript configuration and API
7+
- [Enhancement] Better error message when thumbs directory is missing.
8+
- [Feature] Display a broken file icon, when an image couldn’t be loaded and display alt text, if provided.
9+
- [Enhancement] Make all placeholder sources inline again to guarantee instand placeholder rendering after page load. This increases the initial HTML payload a bit, but results in fewer requests afterwards.
10+
- [Fix] Using the color placeholder style on a completely transparent image will not cause the plugin to fail any more.
511

612
- `1.0.1` (2017/03/22)
713
- Fixes a problem that caused the dynamic presets API to throw a fatal error.

readme.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ A flexible, responsive image component for [Kirby CMS](http://getkirby.com), fea
5959
- **Responsive Images** Add responsive images in different sizes to your website with ease by using ImageSet’s convenient template API.
6060
- **Easy to Use** ImageSet provides a convenient API for generating responsive image sets and also works with Kirbytext.
6161
- **Lazy Loading** It supports lazy loading for saving valuable bandwidth (especially on mobile) and faster page loads for everyone.*
62-
- **Placeholders & Ratios** ImageSet comes with placeholders in 4 beautiful styles and reserves screen space for images to avoid reflows (aka *page-jumps*) while the page is being loaded.
62+
- **Placeholders & Ratios** ImageSet comes with placeholders in 5 beautiful styles and reserves screen space for images to avoid reflows (aka *page-jumps*) while the page is being loaded.
6363
- **Art Direction** Define different sizes and crop ratios for different screen sizes and/or media types.
6464
- **Progressive Enhancement** In case of doubt, the plugin works without JavaScript or native support for responsive images as a conditionally loaded polyfill is included for older browsers.
6565
- **Web Standards** ImageSet produces HTML5-based markup (using the `<picture>` element and `srcset`-attribute).
66-
- **Works with AJAX** ImageSet works with dynamic content, as new imagesets are automatically detected and handled.
67-
- **Small Footprint** Frontend code has been designed for performance and comes with a minimal footprint. Only ~0,7 kB CSS + ~7,5 kB JavaScript (+ 5,7 kB Polyfill for older browsers), when minified & gzipped.
66+
- **Works with AJAX** ImageSet works with dynamic content, as new image sets are automatically detected and handled.
67+
**Error Handling** When an image could not be loaded (e.g. due to a connection error), the plugin will display a broken image icon and alt text if supplied.
68+
- **Small Footprint** Frontend code has been designed for performance and comes with a minimal footprint. Only ~1,5 kB CSS + ~7,5 kB JavaScript (+ 5,7 kB Polyfill for older browsers), when minified & gzipped.
6869

6970
*) Lazy loading uses the very performant [lazysizes](https://github.com/aFarkas/lazysizes) script and requires JavaScript to be activated on the client. However, the plugin provides a `<noscript>`-fallback which is enabled by default.
7071

@@ -133,7 +134,7 @@ In order to make ImageSet work properly, you have to include the corresponding C
133134
<?= css('assets/plugins/imageset/css/imageset.min.css') ?>
134135
```
135136

136-
If you use lazy loading, also add the following line anywhere after the previous code in your template, it is recommended to include the file before the closing `</head>` tag to ensure that it loads as fast as possible.
137+
If you use lazy loading, also add the following line anywhere after the previous code in your template, it is recommended to include the file before the closing `</head>` tag to ensure that it loads as fast as possible. If this is not possible, you can also include the script right before the closing body tag, but this lreads to later execution and can easily result in the flashing of un-rendered placeholders.
137138

138139
```php
139140
<?= js('assets/plugins/imageset/js/dist/imageset.js') ?>
@@ -153,12 +154,31 @@ Not all browsers are providing [native support](http://caniuse.com/#feat=picture
153154
</script>
154155
```
155156

156-
157-
158157
Alright, your site should now be prepared for using ImageSet! :-D
159158

160159
<table><tr><td>ℹ️ For a dev environment or low-traffic sites, it is completely fine to link plugin assets directly. However, if performance is critical for your project, it is highly recommended to place a copy of the JS and CSS files linked above in your <code>assets</code> directory and link to them or to bundle up these assets with your regular CSS and JavaScript using the build tool of your choice.</td></tr></table>
161160

161+
### 2.4 JavaScript Configuration & API
162+
163+
✳️ Available from 1.1.0+
164+
165+
ImageSet does everything automagically, from rendering placeholders to detecting dynamically added image sets. However, there might be some use-cases where you need a bit more control over how the ImageSet plugin works. Configuration is done by settings the global `window.imagesetConfig` variable before loading `imageset.js`. The plugin also exposes a global `imageset` variable to the window object, which is used for calling API methods (currently the only available method is `imageset.update()`).
166+
167+
```html
168+
<script>
169+
window.imagesetConfig = {
170+
autoUpdate: true,
171+
placeholderRendering: 'async',
172+
};
173+
</script>
174+
<!-- include imageset.js after setting up configuration -->
175+
```
176+
177+
| Option | Default value | Possible values | Description |
178+
|:--------------------|:--------------|:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
179+
| `autoUpdate` | `true` | `true`, `false` | If enabled , ImageSet searches for new imagesets whenever the DOM updates. On pages with lots of animations, you might want to prevent that placeholders are being rendered during animations to keep those as smooth as possible. If this setting is disabled, you have to call `imageset.update()` manually after updating the DOM. |
180+
| `placeholderRendering` | `'async'` | `'async'`, `'sync'` | `async` Placeholders are rendered using `requestAnimationFrame()` where available, rendering only one placeholder every frame. On long pages with lots of large images, this keeps the browser responding while the page is being loaded, but can possibly result in the flash of un-rendered placeholders.<br>`sync` Placeholders are rendered immediately after new imagesets are detected. Use this setting when a large amount of smaller imagesets is visible above the fold or when placeholder-rendering could otherwise interfere with animations. |
181+
162182
## 3 Global Configuration
163183

164184
The settings listed below are meant to be defined in your `config.php` and change the global behavior of the plugin. To learn about configuring the default behavior of image sets in your templates (lazy loading, placeholders, fallback behavior etc.), have a look at [4.3.1 Available Options](#431-available-options).

0 commit comments

Comments
 (0)