wp.media in wordpress 3.9.1
-
Or using the WordPress 3.5 Media Uploader in wordpress 3.9.1.
Hi everyone,
I wrote my own plugin with a custom post type and at some point I was uploading picture with the wordpress media uploader.
Everything was working fine, but since yesterday, I upgrade to the new ‘smith’ version (WordPress 3.9.1) and … now that didn’t work anymore.
I’m calling the function wp.media via Jquery on a ‘click’ event, but now my browsers say that :
-> for Firefox 30.0 : ‘wp.media is not a function’
-> for Chrome 35.0.1916.153 m : ‘undefined is not a function ‘ – same line pointed in my js file so I guess that “undefined” means “wp.media”
-> for IE : ‘SCRIPT438: The object didn’t handle the property or method ? media ?’Again, that script was working in WordPress 3.8.1 … so I guess something change.
Here is how I call it :
<div class="meta-box-item-content"> <a href="#" class="button pelliculeUp">Add some pictures </a> <input class="containerOfUploadedUrls" name="picturesUrls" > </div>
And here is the script :
$('.pelliculeUp').click(function(event) { event.preventDefault(); var uploader = wp.media( { title : 'Add images', button : { text : 'Pick files', }, multiple : true }) .on('select', function() { var selection = uploader.state().get('selection'); var attachements = []; selection.map(function(attachement) { attachement = attachement.toJSON(); attachements.push([attachement.id, attachement.url, attachement.caption]); }) $('.containerOfUploadedUrls').val(attachements); }) .open(); });
So, did someone now what can I do for fixing my code ?
His there a new way to use wordpress media uploader in 3.9.1 ?
- The topic ‘wp.media in wordpress 3.9.1’ is closed to new replies.