質問
私のワードプレスのメディアのアップローダーと問題を抱えている、複数の画像を選択午前問題は私は把握できないオブジェクトのすべてのキーをデータベースに格納する 1 つの文字列を連結する方法任意のヘルプはいただければ幸いです、おかげで事前に.
PS のそれが $.each を試みたが、エラーを返します、未定義のプロパティは使用できません
。
もう一:”attachment.url”変数に console.log を試みたし、これはログ:
http://localhost/wp3/wp-content/uploads/2015/01/long-shadow-logo-example.jpg admin.js?ver=4.0.1:16 http://localhost/wp3/wp-content/uploads/2015/01/Firefox.png admin.js?ver=4.0.1:16 http://localhost/wp3/wp-content/uploads/2015/01/fish-logo-designs-32.png
がテキスト ボックスにこの値を追加しようとすると、単一の url が返されます
。
ここでは私の JS コード:
jQuery(document).on("click", ".custom_media_upload", function(e) { e.preventDefault(); var custom_uploader = wp.media({ title: 'Select Images to Use', button: { text: 'Use Selected Images', }, multiple: true // Set this to true to allow multiple files to be selected }) custom_uploader.on('select', function() { var selection = custom_uploader.state().get('selection'); selection.map(function(attachment) { attachment = attachment.toJSON(); console.log(attachment.url); }); //custom_uploader.open(); }); custom_uploader.open(); });
答え
答え
を
この jQuery.each のように変更した場合 $.each が作品だと思います jQuery(document) を使用している
られたリファレンスが JSON を添付ファイルに変換するので。ここでは MDN からの参照: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
http://stackoverflow.com/questions/28207916/js-object-key-and-values-to-a-single-string