mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 01:16:45 +02:00
Blueprint refactor: fix theme thumbnails
This commit is contained in:
@@ -51,6 +51,52 @@ class Blueprint extends BaseBlueprints implements ExportInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get meta value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param string $field Meta field to fetch.
|
||||
* @param mixed $default Default value (or null).
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
*
|
||||
* @return mixed Value.
|
||||
*/
|
||||
public function getMeta($name, $field, $default = null, $separator = '.')
|
||||
{
|
||||
$name = $separator != '.' ? strtr($name, $separator, '.') : $name;
|
||||
|
||||
return isset($this->items[$name]['meta'][$field]) ? $this->items[$name]['meta'][$field] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set meta value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param string $field Meta field to fetch.
|
||||
* @param mixed $value New value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
*/
|
||||
public function setMeta($name, $field, $value, $separator = '.')
|
||||
{
|
||||
$name = $separator != '.' ? strtr($name, $separator, '.') : $name;
|
||||
|
||||
$this->items[$name]['meta'][$field] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define meta value by using dot notation for nested arrays/objects.
|
||||
*
|
||||
* @param string $name Dot separated path to the requested value.
|
||||
* @param string $field Meta field to fetch.
|
||||
* @param mixed $value New value.
|
||||
* @param string $separator Separator, defaults to '.'
|
||||
*/
|
||||
public function defMeta($name, $field, $value, $separator = '.')
|
||||
{
|
||||
$this->setMeta($name, $field, $this->getMeta($name, $field, $value, $separator), $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all form fields in a nested list.
|
||||
*
|
||||
|
||||
@@ -127,7 +127,7 @@ class Themes extends Iterator
|
||||
// Find thumbnail.
|
||||
$thumb = "themes://{$name}/thumbnail.jpg";
|
||||
if ($path = $this->grav['locator']->findResource($thumb, false)) {
|
||||
$blueprint->set('thumbnail', $this->grav['base_url'] . '/' . $path);
|
||||
$blueprint->setMeta('', 'thumbnail', $this->grav['base_url'] . '/' . $path);
|
||||
}
|
||||
|
||||
$obj = new Data($file->content(), $blueprint);
|
||||
|
||||
Reference in New Issue
Block a user