Add random annotation set transform
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -116,6 +116,18 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
|
|
||||||
//Apply any request transformations
|
//Apply any request transformations
|
||||||
if ($this->transform) {
|
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)) {
|
if (in_array('alpha',$this->transform)) {
|
||||||
ksort($annotations);
|
ksort($annotations);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user