Upgrade to 3.1.0
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user