简体   繁体   English

在cq5中将图片组件与xtype html5smartimage一起使用时,如何限制上传图片的大小?

[英]How to limit size of uploaded image when using image component with xtype html5smartimage in cq5?

For image component with xtype html5smartimage, I have tried the sizeLimit option of html5smartimage wih string value 1 assuming will not be able to upload image exceeding 1mb but was able to upload image of a greater size. 对于具有xtype html5smartimage的图像组件,我尝试了html5smartimage的sizeLimit选项,其字符串1假定将无法上传超过1mb的图像,但能够上传更大尺寸的图像。 I did not find any info on the value of sizeLimit except for the fact the default 0 means no limit to the image upload size. 我没有找到有关sizeLimit值的任何信息,除了默认值0表示图像上传大小没有限制。 Please do share any info on sizeLimit option? 请分享有关sizeLimit选项的任何信息吗?

Alternatively, tried listener on image dialog on event loadimage . 或者,在事件loadimage的图像对话框上尝试使用侦听器。 Is able to read image size using this.fileInfo.size Next is to call the clear action of the dialog, when the size exceeds limit. 能够使用this.fileInfo.size读取图像大小,下一步是当大小超出限制时调用对话框的清除操作。 I am yet to figure out where is the out of box clear action of dialog implemented any insight on this would be of great help. 我还没有弄清对话框的开箱即用的透明操作在哪里,对此的任何见解都会有很大的帮助。 crop, rotate are other actions that are available along with the clear action in the image dialog of the component. 裁剪,旋转是其他操作,这些操作与组件的图像对话框中的清除操作一起可用。

Also what would be the best way of doing it or if anyone has solution or suggestions pls do share your information. 另外,最好的方法是什么,或者如果有人有解决方案或建议,请分享您的信息。

This is a known bug in extjs. 这是extjs中的已知错误。 A post exists to explain how to implement this limit for DAM asset UI at: 在以下位置有一篇帖子解释如何对DAM资产UI实施此限制:

http://experience-aem.blogspot.co.uk/2014/12/aem-6-sp1-classic-ui-restrict-large-or-small-files-upload.html http://experience-aem.blogspot.co.uk/2014/12/aem-6-sp1-classic-ui-restrict-large-or-small-files-upload.html

You can probably leverage this to extend the smart image and extend the validation to check the file size. 您可能可以利用它来扩展智能映像并扩展验证以检查文件大小。

HtH 高温

PS: The logic is too long to fit in this answer box but the gist is around validation hooks. PS:逻辑太长,无法容纳在此答案框中,但要点是围绕验证钩子。 Try it from the article and see if it works for you. 从文章中尝试一下,看看它是否适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM