Skip to content
Permalink
Browse files

merge image-helper-network-support

  • Loading branch information
Liblastic committed Dec 13, 2019
1 parent 49fd945 commit b270508d1c197ab86fa591609a9a8104e6d138a5
Showing with 31 additions and 3 deletions.
  1. +2 −2 CHANGELOG.md
  2. +0 −1 README.md
  3. +29 −0 docs/helpers/image.md
@@ -4,12 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [image-helper-network-support] - 2019-12-09
## [1.27.1] - 2019-12-13

### Added
- Added network support for the image helper

## [image-helper-data-filter] - 2019-12-03
## [1.27.0] - 2019-12-03

### Added
- A filter for image helper `$image_data`.
@@ -404,7 +404,6 @@ Example:

The `image` helper returns a markup for `img` tags with proper `srcset` and `sizes` attributes for responsive use. The full readme for the helper can be found [here](docs/helpers/image.md).


### menu

`menu` helper does what it name suggests: it creates a menu. It has several parameters that are explained below:
@@ -28,6 +28,13 @@ If you don't provide the alt parameter when using the helper with an image id, i
``` {@image id=image.id size="medium_large" class="myclass" alt="An alternative text" /} ```
#### Blog id
You can add parameter `blogid` if needed in cross network queries.
Example
``` {@image id=image.id size="large" blogid=data.blogid /} ```
#### A settings model
We recommend using a separate settings model in your DustPress installation for easily defining custom settings for images. This model can be bound to chosen models or even to the middle model which is extended by page and post models.
@@ -57,3 +64,25 @@ class Settings extends \DustPress\Model {
];
}
}
```
#### Image data filter
You can filter $image_data variable with filter `dustpress/image/image_data`.
Example about adding loading="lazy" attribute for all the images with the filter.
```php
/**
* Filter image helper data.
*
* @param array $image_data DustPress image helper data.
*
* @return mixed
*/
function filter_image_helper_data( $image_data ) {
$image_data['attrs']['loading'] = 'lazy';
return $image_data;
}
\add_filter( 'dustpress/image/image_data', 'filter_image_helper_data', 1 );
```

0 comments on commit b270508

Please sign in to comment.
You can’t perform that action at this time.