wordpress upload my media script – Add Media Button – download free

WordPress Image upload Script 100% working

wordpress media script to add the function.php or where you used on template page just copy and past.

For WordPress Developer Search From Correct Code of Upload image Script on Google but i got that correct way of this.


// This will enqueue the Media Uploader script
 <label for="image_url">Image</label>
 <input type="text" name="image_url" id="image_url" class="regular-text">
 <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Upload Image">

<script type="text/javascript">
 $('#upload-btn').click(function(e) {
 var image = wp.media({ 
 title: 'Upload Image',
 // mutiple: true if you want to upload multiple files at once
 multiple: false
 .on('select', function(e){
 // This will return the selected image from the Media Uploader, the result is an object
 var uploaded_image = image.state().get('selection').first();
 // We convert uploaded_image to a JSON object to make accessing it easier
 // Output to the console uploaded_image
 var image_url = uploaded_image.toJSON().url;
 // Let's assign the url value to the input field





Related Posts


No comments.

Leave a Reply