script_backend.js 664 B

1234567891011121314151617181920212223242526272829303132333435
  1. var $ = jQuery;
  2. $(document).ready(function() {
  3. //$("***").ttt();
  4. $('.custom_media').each(function(){
  5. var self = $(this);
  6. $('.custom_media_upload',self).click(function() {
  7. var send_attachment_bkp = wp.media.editor.send.attachment;
  8. wp.media.editor.send.attachment = function(props, attachment) {
  9. $('.custom_media_image',self).attr('src', attachment.url);
  10. var path = "/"+attachment.url.split("/").splice(3).join("/");
  11. $('.custom_media_url',self).val(path);
  12. $('.custom_media_id',self).val(attachment.id);
  13. wp.media.editor.send.attachment = send_attachment_bkp;
  14. }
  15. wp.media.editor.open();
  16. return false;
  17. });
  18. });
  19. });