Added support specifying custom attributes to assets in a collection (fixes #3358)

This commit is contained in:
Djamil Legato
2021-06-03 15:58:28 -07:00
parent c288d4bd0b
commit 8d506db73c
2 changed files with 13 additions and 2 deletions

View File

@@ -1,3 +1,10 @@
# v1.7.17
## mm/dd/2021
1. [](#improved)
* Allow to unset an asset attribute by specifying null (ie, `'defer': null`)
* Support specifying custom attributes to assets in a collection [Read more](https://learn.getgrav.org/17/themes/asset-manager#collections-with-attributes?target=_blank) [#3358](https://github.com/getgrav/grav/issues/3358)
# v1.7.16
## 06/02/2021

View File

@@ -201,8 +201,12 @@ class Assets extends PropertyObject
protected function addType($collection, $type, $asset, $options)
{
if (is_array($asset)) {
foreach ($asset as $a) {
$this->addType($collection, $type, $a, $options);
foreach ($asset as $index => $location) {
if (is_array($location)) {
$options = array_replace_recursive([], $options, $location);
$location = $index;
}
$this->addType($collection, $type, $location, $options);
}
return $this;