Created
August 18, 2018 09:38
-
-
Save sudipto-me/a130810af0ead2f6290d7e31ce34d20b to your computer and use it in GitHub Desktop.
This snippet gives the code for uploading image from media. This click event will open the media directory of the wordpress and gives u privilege to upload media image. Happy Coding. Peace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#similar_product_two_upload_image_button').on('click', function(e) { | |
e.preventDefault(); | |
var send_attachment_bkp = wp.media.editor.send.attachment; | |
wp.media.editor.send.attachment = function(props, attachment) { | |
$('.similar_product_two_upload_src').attr('src', attachment.url); | |
$('#similar_product_two_upload_image').attr('value', attachment.url); | |
wp.media.editor.send.attachment = send_attachment_bkp; | |
} | |
wp.media.editor.open(); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment