首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用ng-file-upload显示缩略图

使用ng-file-upload显示缩略图
EN

Stack Overflow用户
提问于 2017-07-01 08:26:34
回答 2查看 3.2K关注 0票数 0

我使用ng-file-upload来上传图像。我想要显示图像的缩略图。我使用的是angular 1.6。有人可以粘贴选定图像的缩略图的工作代码吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-07-01 08:38:21

ng-file-uploaddocumentation中,有一个自定义指令可用于显示图像的缩略图预览:

代码语言:javascript
复制
<div|span|...
 *ngf-thumbnail="file" // Generates a thumbnail version of the image file
 ngf-size="{width: 20, height: 20, quality: 0.9}"
    // the image will be resized to this size
    // if not specified will be resized to this element`s client width and height.
 ngf-as-background="boolean"
   // if true it will set the background image style instead of src attribute.
>

下面是一个缩略图标记的示例

代码语言:javascript
复制
<img class="your_class"
     ngf-thumbnail="path/to/file.jpg"
     ngf-size="{width:200, height:200, quality:1.0}"/>
票数 2
EN

Stack Overflow用户

发布于 2018-12-04 01:43:59

从版本5.1.0开始使用ngf-background指令。

代码语言:javascript
复制
<div class="your-thumbnail-class" ng-show="!!yourModel" ngf-background="yourModel"></div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44856328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档