/* var $ = jQuery; $(document).ready(function() { //$("***").ttt(); console.log("OKOKOKO K plugin"); var mediaUploader; $('#upload_image_button').click(function(e) { e.preventDefault(); if (mediaUploader) { mediaUploader.open(); return; } mediaUploader = wp.media.frames.file_frame = wp.media({ title: 'Choose Image', button: { text: 'Choose Image' }, multiple: false }); mediaUploader.on('select', function() { var attachment = mediaUploader.state().get('selection').first().toJSON(); console.log("LLLL",attachment); $('#background_image').attr("src",attachment.url); }); mediaUploader.open(); }); $('.custom_media').each(function() { var self = $(this); $('.custom_media_upload', self).click(function() { var send_attachment_bkp = wp.media.editor.send.attachment; wp.media.editor.send.attachment = function(props, attachment) { $('.custom_media_image', self).attr('src', attachment.url); var path = "/" + attachment.url.split("/").splice(3).join("/"); $('.custom_media_url', self).val(path); $('.custom_media_id', self).val(attachment.id); wp.media.editor.send.attachment = send_attachment_bkp; } wp.media.editor.open(); return false; }); }); }); */