Skip to content

Commit

Permalink
Added support specifying custom attributes to assets in a collection (f…
Browse files Browse the repository at this point in the history
…ixes #3358)
  • Loading branch information
w00fz committed Jun 3, 2021
1 parent c288d4b commit 8d506db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -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

Expand Down
8 changes: 6 additions & 2 deletions system/src/Grav/Common/Assets.php
Expand Up @@ -201,8 +201,12 @@ public function add($asset)
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;
Expand Down

0 comments on commit 8d506db

Please sign in to comment.