mirror of
https://github.com/getgrav/grav.git
synced 2026-02-06 06:40:29 +01:00
Added support to set classes and id on a medium object
This commit is contained in:
@@ -214,8 +214,9 @@ class Medium extends Data implements RenderableInterface
|
||||
else
|
||||
$style .= $key . ': ' . $value . ';';
|
||||
}
|
||||
if ($style)
|
||||
if ($style) {
|
||||
$attributes['style'] = $style;
|
||||
}
|
||||
|
||||
if (empty($attributes['title'])) {
|
||||
if (!empty($title)) {
|
||||
@@ -392,6 +393,38 @@ class Medium extends Data implements RenderableInterface
|
||||
return $this->link($reset, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a class to the element from Markdown or Twig
|
||||
* Example:  or 
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function classes()
|
||||
{
|
||||
$classes = func_get_args();
|
||||
if (!empty($classes)) {
|
||||
$this->attributes['class'] = implode(',', (array)$classes);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an id to the element from Markdown or Twig
|
||||
* Example: 
|
||||
*
|
||||
* @param $id
|
||||
* @return $this
|
||||
*/
|
||||
public function id($id)
|
||||
{
|
||||
if (is_string($id)) {
|
||||
$this->attributes['id'] = trim($id);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to add an inline style attribute from Markdown or Twig
|
||||
* Example: 
|
||||
|
||||
Reference in New Issue
Block a user