Add random annotation set transform

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-11-15 08:59:50 -07:00
parent 9f8995dcf3
commit e9dc663c0f

View File

@@ -116,6 +116,18 @@ class GlModelTransformOutput extends MediaTransformOutput {
//Apply any request transformations
if ($this->transform) {
if (in_array('rand',$this->transform)) {
$subKey = array_search('rand',$this->transform);
$subs = is_numeric($this->transform[$subKey + 1]) ? $this->transform[$subKey + 1] : count($annotations);
$keys = array_keys($annotations);
shuffle($keys);
$keys = array_slice($keys, 0 , $subs);
$newAnnot = array();
foreach ($keys as $key) {
$newAnnot[$key] = $annotations[$key];
}
$annotations = $newAnnot;
}
if (in_array('alpha',$this->transform)) {
ksort($annotations);
}