In the tables/products/fields.ini file find the section pertaining to the product_image field:
- Code: Select all
[product_image]
Type=container
allowed_extensions="jpg,gif,png"
visibility:list = hidden
visibility:list = hidden
Add the maxfilesize validator to this section. E.g.:
- Code: Select all
validators:maxfilesize = 32000
This would limit the upload size to 32k (i.e. the size is specified in bytes).
The user would then get an error message saying that the product_image field had illegal input. You may want to provide your own custom error message for this case to make it more clear that the problem was that the file was too big. In this case you could add:
- Code: Select all
validators:maxfilesize:message = "The file you uploaded was too big!!"
So when you're done, the product_image section might look something like:
- Code: Select all
[product_image]
Type=container
allowed_extensions="jpg,gif,png"
visibility:list = hidden
visibility:list = hidden
validators:maxfilesize = 32000
validators:maxfilesize:message = "The file you uploaded is too big!!"
On some of my sites I have integrated an image server script to automatically shrink images to avoid this problem... but I'll save that for another post.
Best regards
Steve