精细上传器 - 获得宽度和宽度选择/上载图像后的高度尺寸 [英] Fine Uploader - Get Width & Height Dimensions once Image is Selected/Uploaded

查看:136
本文介绍了精细上传器 - 获得宽度和宽度选择/上载图像后的高度尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用精细上传器我需要能够以像素为单位获取所选文件的原始宽度和高度尺寸,以便我可以将它们用于我的页面以后使用。有没有办法在选择文件后或在完成成功回调时执行此操作?

Using fine-uploader i need to be able to get the selected file's original width and height dimensions in pixels so that i can use them for later use on my page. Is there a way to do this either once the file is selected or on the on complete success callback?

推荐答案

Fine Uploader doesn'提供此类数据,但您可以自行确定图像的尺寸。首先,将图像文件转换为对象URL( URL.createObjectURL(file)),然后将该URL用作img元素的src属性。最后,在完全呈现< img> 之后,检查元素的width和height属性。当要求根据特定尺寸限制验证图像文件时,Fine Uploader会在内部执行此操作。请参阅图像验证代码的例子。

Fine Uploader doesn't provide this type of data, but it's simple to determine the dimensions of an image yourself. First, convert the image file to an object URL (URL.createObjectURL(file)) then use that URL as the src attribute of an img element. Finally, after the <img> has completely rendered, check the width and height properties of the element. Fine Uploader does this internally when it is asked to validate an image file based on specific dimension limits. See the image validation code for an example.

这篇关于精细上传器 - 获得宽度和宽度选择/上载图像后的高度尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆