javascript jQuery 图像选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3339013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery image picker
提问by elsurudo
I'm looking for a jQuery image picker plugin that allows me to do the following:
我正在寻找一个 jQuery 图像选择器插件,它允许我执行以下操作:
- Display a group of images and let the user select one (and only one) by clicking it
- If the user does not like any of the specified images, he should be able to upload his own
- 显示一组图像并让用户通过单击选择一个(并且只有一个)
- 如果用户不喜欢任何指定的图像,他应该可以上传自己的
Just #1 would suffice, as I can add the code for #2 if necessary
只需 #1 就足够了,因为我可以在必要时添加 #2 的代码
It's not that difficult to do I know, but if there is a standard plugin that people use for this, I'd rather use that than reinvent the wheel.
我知道这并不难,但如果有人们为此使用的标准插件,我宁愿使用它而不是重新发明轮子。
回答by RVera
I know this has already been answered but I actually developed a library that address the first problem. You can check it out here:
我知道这已经得到了回答,但我实际上开发了一个解决第一个问题的库。你可以在这里查看:
回答by Ties
Something like this? i dont know if there is plugin but is seems really simple
像这样的东西?我不知道是否有插件但看起来很简单
// HTML
<div id="image_container">
<img src="blabla" />
<img src="blabla" />
...
</div>
<form ...>
<input id="image_from_list" name="image_from_list" type="hidden" value="" />
<input id="image_from_file" name="image_from_file" type="file" />
</form>
// JS
$('div#image_container img').click(function(){
// set the img-source as value of image_from_list
$('input#image_from_list').val( $(this).attr("src") );
});
回答by supertramp
Have you tried this:
你有没有试过这个:
https://code.google.com/p/select-to-image-picker-jquery/
https://code.google.com/p/select-to-image-picker-jquery/
It lets you to change select box into image picker based on JQueryUI modal box.
它允许您将选择框更改为基于 JQueryUI 模态框的图像选择器。
I was looking for something like this a long time and finally needed to develop it by myself. So maybe you will find useful too.
这样的东西找了很久,终于需要自己开发了。所以也许你也会觉得有用。

