Skip to content

Commit 8c10504

Browse files
committed
Handle crop ratio
1 parent 222e94e commit 8c10504

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/OzuCms/Form/OzuImageField.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class OzuImageField extends OzuField
77
private array $allowedExtensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
88
private int $maxFileSizeInMB = 5;
99
private bool $hasLegend = false;
10+
private ?string $cropRatio = null;
1011

1112
public function setHasLegend(bool $hasLegend = true): self
1213
{
@@ -29,6 +30,13 @@ public function setMaxFileSizeInMB(int $maxFileSizeInMB): self
2930
return $this;
3031
}
3132

33+
public function setCropRatio(string $cropRatio): self
34+
{
35+
$this->cropRatio = $cropRatio;
36+
37+
return $this;
38+
}
39+
3240
public function type(): string
3341
{
3442
return 'image';
@@ -40,6 +48,7 @@ public function toArray(): array
4048
'hasLegend' => $this->hasLegend,
4149
'allowedExtensions' => $this->allowedExtensions,
4250
'maxFileSize' => $this->maxFileSizeInMB,
51+
'cropRatio' => $this->cropRatio,
4352
]);
4453
}
4554
}

src/OzuCms/Form/OzuImageListField.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,24 @@
44

55
class OzuImageListField extends OzuFileListField
66
{
7+
private ?string $cropRatio = null;
8+
79
public function type(): string
810
{
911
return 'imageList';
1012
}
13+
14+
public function setCropRatio(string $cropRatio): self
15+
{
16+
$this->cropRatio = $cropRatio;
17+
18+
return $this;
19+
}
20+
21+
public function toArray(): array
22+
{
23+
return array_merge(parent::toArray(), [
24+
'cropRatio' => $this->cropRatio,
25+
]);
26+
}
1127
}

0 commit comments

Comments
 (0)