Execute
Save
Share
Share link
share
share
share
Team
Public Teams
Comments
0
Created By:
Guest
Title:
Title
Description
Edit
Copy Link
Login
Email *
Password *
Login
OR
Create Account
Screen Name *
Email *
Password *
Retype Password *
Team Access Code
Register
Public CodeBins
HELP
--Select Theme--
Ambiance
Blackboard
Cobalt
Eclipse
Elegant
Erlang-Dark
Lesser-Dark
Monokai
Neat
Night
Rubyblue
Vibrant-Ink
Xq-Dark
New CodeBin
CodeBins Versions
08/28/2013- V.2
08/28/2013- V.1
Compare Versions
Recent CodeBins
View All CodeBins
jQuery(function(jQuery) { if (typeof wp.media != 'undefined') { // Uploading files var file_frame; var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id var set_to_post_id = 5; // Set this formfield = jQuery(this).siblings('.custom_upload_image'); preview = jQuery(this).siblings('.custom_preview_image'); // Create the media frame. file_frame = wp.media.frames.file_frame = wp.media({ multiple: false // Set to true to allow multiple files to be selected }); // When an image is selected, run a callback. file_frame.on('select', function() { // We set multiple to false so only get one image from the uploader attachment = file_frame.state().get('selection').first().toJSON(); imgurl = attachment.url; id = attachment.id; console.log(attachment); var inputfield = wp.media.model.settings.post.id; jQuery('input.custom_upload_image[name=' + inputfield + ']').val(id); jQuery('input.custom_upload_image[name=' + inputfield + ']').parents('td').find('.custom_preview_image').attr('src', imgurl); // Restore the main post ID wp.media.model.settings.post.id = wp_media_post_id; }); jQuery('.custom_upload_image_button').click(function(e) { e.preventDefault(); var set_to_post_id = jQuery(this).parents('td').find('.custom_upload_image').attr('name'); wp.media.model.settings.post.id = set_to_post_id; // Open frame file_frame.open(); // Finally, open the modal file_frame.open(); }); // Restore the main ID when the add media button is pressed jQuery('a.add_media').on('click', function() { wp.media.model.settings.post.id = wp_media_post_id; }); jQuery('.custom_clear_image_button').click(function(e) { e.preventDefault(); jQuery(this).parents('td').find('.custom_upload_image').val(''); jQuery(this).parents('td').find('.custom_preview_image').attr('src', '/wp-content/themes/YESpeopleandprojects/images/image.png'); }); } });
Bottom of Page
In Head
On Load
On Ready
Setting
Validate
Copy
Format
Setting
Validate
Copy
Format
No Doc Type
HTML5
HTML 4.01 Transitional
HTML 4.01 Strict
HTML 4.01 Frameset
XHTML 1.1
XHTML 1.0 Transitional
XHTML 1.0 Strict
XHTML 1.0 Frameset
Copy
Format
Download
×
Code Description
×
Difference of Versions
HTML
CSS
JS
×
JS Error
×
CSS Error
Errors
Warnings
×
JavaScript Setting
JS Libraries:
Chrome Frame 1.0.3
Dojo 1.8.0
Dojo 1.7.3
Dojo 1.7.2
Ext Core 3.1.0
jQuery 1.8.0
jQuery 1.7.2
jQuery 1.6.0
jQuery 1.5.0
jQuery 1.4.4
jQuery 1.4.0
jQuery-min 1.7.2
jQueryUI-min 1.8.21
MooTools more-1.4.0.1-full
MooTools core-1.4.5-full
MooTools core-1.4.1-full
Prototype 1.7.1.0
script.aculo.us 1.9.0
SWFObject 2.2
Twitter Bootstrap 2.0.4
WebFont Loader 1.0.28
yui 3.5.1
User Libraries:
Upload File
JavaScript URL(s):
×
CSS Setting
CSS Libraries:
jQueryUI 1.8.21
Twitter Bootstrap 2.0.4
User Libraries:
Upload File
CSS URL(s):