I followed this code as below but it gives me the error "wp not defined
". I placed the code inside footer.php in my child theme and also in functions.php but both are erroneous.
(function($){
$.extend( wp.Uploader.prototype, {
success : function( file_attachment ){
console.log( file_attachment );
}
});
})(jQuery);
wp
is not defined, because the rest of the code is missing and wasn't mentioned in the question. They only shared the parts they were having problems withwp
is missing, andwp.Uploader
. The media library scripts don't get loaded on the frontend unless you make the effort to enqueue them. The Q you tried to use only has small snippets of a much larger piece of code that wasn't shared, including some PHP in a plugin or function.php file. That question cannot be used as an example of how to create an uploader on the frontend, or how to load the media library