manually merged new attribute() method #3065

This commit is contained in:
Andy Miller
2021-02-09 13:09:31 -07:00
parent 6ed28c5fb8
commit 13f8b65e08
3 changed files with 26 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
# v1.7.6
## mm/dd/2021
1. [](#new)
* Added `Medium::attribute()` to pass arbitrary attributes [#3065](https://github.com/getgrav/grav/pull/3065)
1. [](#improved)
* Added abstract `FlexObject`, `FlexCollection` and `FlexIndex` classes to `\Grav\Common\Flex` namespace (extend those instead of Framework or Generic classes)
* Updated bundled `composer.phar` binary to latest version `2.0.9`

View File

@@ -115,6 +115,15 @@ interface MediaObjectInterface extends \Grav\Framework\Media\Interfaces\MediaObj
*/
public function reset();
/**
* Add custom attribute to medium.
*
* @param string $attribute
* @param string $value
* @return $this
*/
public function attribute($attribute = null, $value = '');
/**
* Switch display mode.
*

View File

@@ -303,6 +303,21 @@ trait MediaObjectTrait
return $this;
}
/**
* Add custom attribute to medium.
*
* @param string $attribute
* @param string $value
* @return $this
*/
public function attribute($attribute = null, $value = '')
{
if (!empty($attribute)) {
$this->attributes[$attribute] = $value;
}
return $this;
}
/**
* Switch display mode.
*