我已在前端排队 wp_enqueue_media();
。
我添加了两种按钮,一种用于单选,第二种用于多图像选择
if($(this).hasClass('multiple-image-button')) {
// Set the wp.media attributes
var send_attachment_multiple = wp.media({
title : 'Choose or Upload an Image',
multiple: true,
library: {
type: [ 'image' ]
},
});
} else {
//uploadSingleImages(this);
// Set the wp.media attributes
var send_attachment_multiple = wp.media({
title : 'Choose or Upload an Image',
multiple: false,
library: {
type: [ 'image' ]
},
});
}
一切正常。现在我认为的问题是 WordPress 媒体库如何处理多个图像选择。当选择多个图像时,它强制用户单击 Shift/Ctrl 并单击图像以选择所有需要的图像(这对于桌面来说是可以的)。
现在,当我在移动设备上时,即使多重选择等于true
,我也无法选择多个图像。
这就是它目前的工作方式(通常的 WordPress 行为也在后端)
这就是多图像选择的工作方式(点击时无需 Shift/Ctrl/等等)
尝试选择多个图像时启用批量选择的最佳方法是什么?或者有什么想法如何实现这一点?
最佳答案
我无法想象解决方案会如此简单。花了很多时间后我找到了解决方案..因此,如果您想在不使用shift/ctrl/等的情况下选择多个图像(这意味着仅在单击时),您需要替换
multiple: true,
与
multiple: 'add',
关于jquery - WordPress 媒体库单击时选择多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66719776/