Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($('#menu-to-edit')) {
- var file2_frame = wp.media.featuredImage.frame();
- }
- $('#menu-to-edit').delegate('.set-post-thumbnail', 'click', function( event ) {
- var obj = '';
- event.preventDefault();
- event.stopPropagation();
- var obj = $(this);
- console.log(obj);
- file2_frame.on('select',function() {
- attachment = file2_frame.state().get('selection').first().toJSON();
- var img_obj = obj.data('targetimg');
- var img_id = obj.data('targetid');
- var item_id = obj.data('itemid');
- $.post(ajaxurl,{action:'set_thumbnail',id:attachment.id,item:item_id}, function(data){
- if (data == 1) {
- console.log('wena');
- }
- });
- //console.log( img_obj );
- $('.'+img_obj).attr('src', attachment.sizes.thumbnail.url);
- $('.'+img_id).val(attachment.id);
- console.log(attachment);
- file2_frame.state('destroy');
- });
- file2_frame.open();
- return false;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment