Upgrade to 3.1.0

This commit is contained in:
Bastian Allgeier
2019-03-19 11:07:14 +01:00
parent 418db4b09b
commit 6e074142f1
98 changed files with 1266 additions and 299 deletions

View File

@@ -90,6 +90,46 @@ trait FileModifications
]);
}
/**
* Create a srcset definition for the given sizes
* Sizes can be defined as a simple array. They can
* also be set up in the config with the thumbs.srcsets option.
* @since 3.1.0
*
* @param array|string $sizes
* @return string
*/
public function srcset($sizes = null): ?string
{
if (empty($sizes) === true) {
$sizes = $this->kirby()->option('thumbs.srcsets.default', []);
}
if (is_string($sizes) === true) {
$sizes = $this->kirby()->option('thumbs.srcsets.' . $sizes, []);
}
if (is_array($sizes) === false || empty($sizes) === true) {
return null;
}
$set = [];
foreach ($sizes as $key => $value) {
if (is_string($value) === true) {
$size = $key;
$attr = $value;
} else {
$size = $value;
$attr = $value . 'w';
}
$set[] = $this->resize($size)->url() . ' ' . $attr;
}
return implode(', ', $set);
}
/**
* Creates a modified version of images
* The media manager takes care of generating