gpt4 book ai didi

image-uploading - Plupload 创建多个大小的缩略图

转载 作者:行者123 更新时间:2023-12-04 18:10:47 24 4
gpt4 key购买 nike

我在客户端创建和上传缩略图图像时发现了这个线程。踏板显示如何上传第一张图片,然后通过调整大小并再次上传来跟进。我想知道是否有一种简单的方法可以添加另一个步骤,以便最终结果会产生原始、中等大小和缩略图

A better solution is to trigger QueueChanged in the FileUploaded handler, and then call refresh. This will initiate the upload again for the same file and you can set a property that you read in the BeforeUpload handler to adjust the file size.

警告#1:您应该在全尺寸图像之后上传缩略图,否则全尺寸图像可能会出现一些缓冲区问题并被截断。

警告 #2:这仅在对 FileUploaded 的绑定(bind)调用发生在 uploader.init() 之后才有效,否则上传者自己的 FileUploaded 处理程序将在您的处理程序之后将 file.status 覆盖回 DONE。

下面是这个帖子的原始回复 Plupload Thumbnail
uploader.bind('BeforeUpload', function(up, file) {
if('thumb' in file)
up.settings.resize = {width : 150, height : 150, quality : 100};
else
up.settings.resize = {width : 1600, height : 1600, quality : 100};
}

uploader.bind('FileUploaded', function(up, file) {
if(!('thumb' in file)) {
file.thumb = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();
}
}

最佳答案

很简单,我在我的项目中就是这样做的,做了两个小调整。

在upload.php中,我动态地制作了目录信息:

$diretorio = $_REQUEST["diretorio"];
$targetDir = 'upload/'.$diretorio;

并更改了上传界面中的代码:
uploader.bind('BeforeUpload', function(up, file) {
if('thumb' in file){

//thumb
up.settings.url = 'upload/upload.php?diretorio=thumbs',
up.settings.resize = {width : 100, height : 75, quality : 60};

// medium size
up.settings.url = 'upload/upload.php?diretorio=medium',
up.settings.resize = {width : 200, height : 150, quality : 60};

}else{
up.settings.url = 'upload/upload.php?diretorio=full-size',
up.settings.resize = {quality : 100};
}
uploader.bind('FileUploaded', function(up, file) {
if(!('thumb' in file)) {
file.thumb = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();
}
});
});

关于image-uploading - Plupload 创建多个大小的缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14762529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com