Created
July 18, 2013 13:22
-
-
Save UmeshSingla/6029248 to your computer and use it in GitHub Desktop.
Media Uploader Wordpress
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
jQuery(document).ready(function(){ | |
var _rtp_media = true, | |
_orig_send_attachment = wp.media.editor.send.attachment; | |
jQuery('.rtp-media-uploader').click(function () { | |
var button = jQuery(this), | |
textbox_id = jQuery(this).attr('data-id'); | |
_rtp_media = true; | |
wp.media.editor.send.attachment = function (props, attachment) { | |
if ( _rtp_media && ( attachment.mime === 'application/pdf' ) ) { | |
jQuery( '#'+ textbox_id ).val( attachment.id ); | |
button.next().show(); | |
} else { | |
alert('Please select a valid PDF file'); | |
return false; | |
} | |
} | |
wp.media.editor.open(button); | |
return false; | |
}); | |
jQuery('.add_media').on('click', function(){ | |
_rtp_media = false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment