问题描述

Elliot 在这里从 “高级自定义字段” 插件。

我正在将新的 WP 3.5 上传器集成到 ACF 插件中,并且根本找不到关于新上传者的许多文档!

创建上传框架很容易,可以这样做:

// Create the media frame.
acf.media = wp.media({
    title : 'title',
    button : {
        text: 'button',
    },
    multiple: true
});

但是,如果要将多个值更改为 false 并为另一个字段更改?基本上,我只想创建一个 wp.media 对象,但是当需要时更新选项 (当你点击”upload image” 等等),并强制在上传者上渲染刷新。

我玩过这样的东西:

acf.media.title.get().refresh()

但这不行吗

任何帮助将会非常重要

干杯艾略特

最佳解决方案

解决了!

不知道这是否是正确的方法,但在几个小时的控制台日志之后,我发现这个代码:

acf.media.content.get().options.selection.multiple = false

将更新多个选项,从而更改新上传者中可以选择的图像数量。

如果有人找到更好的方式,我很乐意听到

次佳解决方案

看起来你已经弄清楚了,但看到我使用 ACF,所有的时间,我想我可以链接到几个关于媒体上传者的一些关于媒体上传者的文章,因为 codex 还没有更新。

退房:Using the WordPress 3.5 Media Uploader within plugins

This week whilst working on WooCommerce 2.0 beta I was faced with the task of rewriting the media unloaders to use the fancy new interface in 3.5 instead of the tired old thickbox modal windows used in earlier versions.

This was no easy task mainly due to the lack of documentation available for the new system, but I persevered and wanted to share my experiences in this post.

Building a Better Image Widget with the New WordPress Media Manager

I decided to build a better image widget — something seemingly simple that’s not too different from the featured image workflow and could be used as a starting point. I was fairly satisfied with my initial effort, but the code in the post thumbnail meta box didn’t resemble an API and it was eventually reverted to maintain compatibility.

保持与 ACF 的伟大的工作:)

参考文献

注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。