简体   繁体   English

无法让ngf-resize与ng-file-upload一起使用

[英]Can't get ngf-resize to work with ng-file-upload

I'm working on an angular-meteor app, and following the official tutorial , I'm using ng-file-upload to upload images. 我正在开发一个流星应用程序,并按照官方教程进行操作 ,使用ng-file-upload上传图像。 I'm trying to resize an image on the client. 我正在尝试在客户端上调整图像大小。 I'm pretty sure I'm just missing something basic about how to use this directive. 我敢肯定,我只是缺少一些有关如何使用此指令的基本知识。 This is my html snippet: 这是我的html代码段:

<div ngf-drop ngf-select
     ngf-change="createLocationCtrl.addImages($files)"
     ngf-drag-over-class="{accept:'dragover', reject:'dragover-err', delay:100}" class="drop-box"
     ngf-multiple="false" ngf-allow-dir="false" ngf-accept="'image/*'"
     ngf-drop-available="true"
     ngf-resize="{width:300, height:300, centerCrop:true}">
      Select File or Drop File
</div>

Then when I input an image file and break in the console on createLocationCtrl.addImages I see that the file was inputted completely unchanged. 然后,当我输入一个图像文件并在createLocationCtrl.addImages的控制台中中断时,我看到该文件的输入完全不变。

I tried adding ngf-resize-if="true" and to play around even more yet nothing worked. 我尝试添加ngf-resize-if =“ true”并进行更多操作,但没有任何效果。

Any help would be appreciated! 任何帮助,将不胜感激!

I had same problem and I was looking for some solution for a time without luck. 我遇到了同样的问题,而且一段时间以来一直在寻找一些解决方案,但没有运气。 Until now I understood the problem. 到目前为止,我了解问题所在。

When you upload an svg file and try to resize it, then this conversion is done as a png file. 当您上传svg文件并尝试调整其大小时,此转换将作为png文件进行。

So, when you upload the file you MUST CHANGE THE EXTENSION to PNG or exclude svg files 因此,当您上传文件时,必须将扩展名更改为PNG或排除SVG文件

ngf-resize-if="TRUE && $file.type !== 'image/svg+xml'"

(change TRUE, for your current condition) (根据您的当前情况更改TRUE)

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

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