Passing jQuery into the WordPress media uploader

As you mention the media uploader dynamically renders the images “on demand” and there doesn’t seem to be an event one can target to add the class. A gross way to do it is to override the wp.media.view.Attachment.Library.className attribute (before the frame is created) to return the extra class if the model id is in … Read more

Add / Update Custom Fields After Select Pictures in Media Window

I modify my jquery / js like this.. $(document).ready(function(){ // $(‘#insert-my-media’).click(open_media_window); if($(‘#images_id’).val() != ” && $(‘#images_url’).val() != ”){ $(‘#open_media’).text(“Edit Slider”); } $(‘#open_media’).click(function(e){ e.preventDefault(); var target = $(‘#images_id’); var target_url = $(‘#images_url’); var btnSave = $(‘#publishing-action input.button’); if(target.val() == ” && target_url.val() == ”){ var wpmedia = wp.media({ title: ‘Insert a media’, library: {type:’image’}, multiple: true, … Read more

Limit filetype and wp media

I have shown your questions and i have found correction in it. You need to update your code as below. .on( ‘select’, function() { var attachment = custom_uploader.state().get( ‘selection’ ).first().toJSON(); if(attachment.mime == “image/jpg” || attachment.mime == “image/jpge” || attachment.mime == “image/png”) { jQuery( ‘#previewImage’ ).attr( ‘src’, attachment.url ); jQuery( ‘.custom_media_url’ ).val( attachment.url ); jQuery( ‘.custom_media_id’ … Read more

Why does javascript works only if logged in?

Try: wp_enqueue_script( ‘nevermind-navigation’, get_template_directory_uri() . ‘/js/navigation.js’, array(‘jquery’) ); It is possible that jQuery is not enqueued, and you are not declaring it as a dependency for your script. Being logged in, automatically enqueues jQuery. EDIT: Console log says jQuery is not defined. Did you add a jQuery(document).ready($) function for the fixed-menu.js functions?