आप इस कोड का उपयोग करके वर्डप्रेस डिफ़ॉल्ट मीडिया फ़ाइल अपलोडर का उपयोग कर सकते हैं और बस jQuery में
<label for="upload_image">
<input id="upload_image" type="text" size="36" name="ad_image" value="http://" />
<input id="upload_image_button" class="button" type="button" value="Upload Image" />
<br />Enter a URL or upload an image
</label>
<?php
add_action('admin_enqueue_scripts', 'my_admin_scripts');
function my_admin_scripts() {
if (isset($_GET['page']) && $_GET['page'] == 'my_plugin_page') {
wp_enqueue_media();
wp_register_script('my-admin-js', WP_PLUGIN_URL.'/my-plugin/my-admin.js', array('jquery'));
wp_enqueue_script('my-admin-js');
}
}
?>
<script>
jQuery(document).ready(function($){
var custom_uploader;
$('#upload_image_button').click(function(e) {
e.preventDefault();
//If the uploader object has already been created, reopen the dialog
if (custom_uploader) {
custom_uploader.open();
return;
}
//Extend the wp.media object
custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Choose Image',
button: {
text: 'Choose Image'
},
multiple: true
});
//When a file is selected, grab the URL and set it as the text field's value
custom_uploader.on('select', function() {
console.log(custom_uploader.state().get('selection').toJSON());
attachment = custom_uploader.state().get('selection').first().toJSON();
$('#upload_image').val(attachment.url);
});
//Open the uploader dialog
custom_uploader.open();
});
});
</script>
स्रोत
2015-06-19 09:28:09
http://www.webmaster-source.com/2010/01/08/using- छवि के लिंक को पुनः प्राप्त द वर्डप्रेस-अपलोडर-इन-यू-प्लगइन-या-थीम/ – Anonymous
मैंने इस बारे में एक ट्यूटोरियल लिखा, वर्डप्रेस से ड्रॉप डाउन मीडिया अपलोडर का उपयोग कैसे करें :) http://www.cedricve.me/2012/03/ 31/उपयोग-द-बिल्ट-इन-वर्डप्रेस-अपलोडर-इन-यू-यू-डब्ल्यूपी-प्लगइन/उम्मीद है कि यह आपको या किसी और की मदद करेगा। एक अच्छा दिन –