Is there any specific way how we can restrict upload image ratio to 16:9 in cakephp 2.3?
Asked
Active
Viewed 132 times
0

HaveNoDisplayName
- 8,291
- 106
- 37
- 47

Shrish Shrivastava
- 535
- 6
- 20
-
Not really but PHP provides functions to handle that. With getimagesize(), you will be able to manually calculate this ratio. http://php.net/manual/fr/function.getimagesize.php – richerlariviere Jul 17 '15 at 13:10
-
1I know this is not about the question, but if you're new to CakePHP and you want to implement a image upload module, I have a tip for you: Keep the upload code in the model. Use model's callbacks (beforeSave(), afterSave()) to manage your upload. Remember that: Fat model, tiny controller. – richerlariviere Jul 17 '15 at 13:14
1 Answers
0
I don't think you did any research on this yourself... So here is just the basic concept:
- Don't use a component, use a model or behavior instead
- Create a custom validation rule
- Get the image size inside the rule, calculate the ratio and (in)validate the file field if it doesn't match your ratio.