問題描述
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 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。