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' ).val( attachment.id );
}
else
{
alert("Please select jpg,jpeg and png type images only");
custom_uploader.open();
return;
}
})
Thanks you!
Related Posts:
- Add tinymce buttons to caption textarea in media uploader
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- Why does my media selection script write to ONLY the first input field?
- JavaScript sleep/wait before continuing [duplicate]
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How do I link a JavaScript file to a HTML file?
- jQuery equivalent of JavaScript’s addEventListener method
- Adding an onclick function to go to url in JavaScript?
- Checking a Url in Jquery/Javascript
- Best way to store a key=>value array in JavaScript?
- When and why to ‘return false’ in JavaScript?
- Format date to MM/dd/yyyy in JavaScript
- How is JavaScript .on() method defined?
- Javascript isnull
- JQuery: $.get is not a function
- How to read data From *.CSV file using javascript?
- How can I expand and collapse a using javascript?
- Javascript : array.length returns undefined
- I want to enqueue a .js file to my child theme
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- How to prevent wordpress from loading old versions of jquery in wp_head();?
- Add custom shortcode button to Editor
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- How to get a jQuery script to run on a page?
- Defer Parsing of Scripts
- Modify Custom Field in Media Library using JavaScript
- Including javascript for a shortcode
- Asynchronous Javascript Loaders
- Unable to run jQuery script in my template file
- How to Use JSON With AJAX?
- Using wp_ajax and wp_ajax_nopriv hooks
- Prevent five different copies of jquery from being included on every page
- Hide/show customizer controls based on other settings in Customizer
- How do I get my page to load the jQuery UI Effects library?
- javascript is not working on Event Submission?
- How to add unique image class to WordPress
- WP Media uploader loading only once in options page
- Dropzonejs with WPCF7 [closed]
- jQuery Tree View and wp_list_pages
- Jquery conflict
- WordPress audio player causing js error, mediaelementplayer is not a function
- Auto-detect javascript errors and warn theme user
- combining js scripts from a js newb [closed]
- Loading posts via AJAX in a hidden div with updated URL?
- Heartbeat API: How to access data already enqueued?
- Implementing lazy loading in homepage posts instead of pagination
- How to show jquery popup only in one page or once?
- Correct way to write jQuery functions in WordPress
- WooCommerce Ajax Cart Update Stopped Working
- Using bootstrap-slider and bootstrap-switch in wordpress admin panel
- Trouble with WordPress Ajax Login System – 302
- window.onload wont execute in wordpress
- How to return multiple arguments from AJAX callback function
- JS news ticker is not working on home page but working on other pages. How to solve this?
- WP Customizer compare and set a value via javascript
- “JQMIGRATE: Migrate is Installed” How do I find the problem code? [duplicate]
- Referrer URL with jQuery or Javascript – Cache & Referrer URL Issue
- Create special WordPress slideshow with “jquery.cycle.all.js”
- Using Foundation 5 in WordPress Administration Area
- Plugin Scripts no loading on options page
- Ajax Validation for reCaptcha
- Using jquery and javascript in WordPress
- Disable Cloudflare Rocket Loader for jQuery javascript and make it load first
- jQuery selectable() function won’t work in wordpress
- oEmbed Video in Modal
- AJAX Success Function using JS substr() fails in WP 4.1 vs 4.0
- How To Include JavaScript Files Only In Single Posts?
- wordpress before or after javascript problem
- Ajax page load in wordpress the right way?
- I am trying to Implement a Code that is Working in my previous page but not working in WordPress for some reason
- How to use $ with externally loaded javascript
- Getting click on item to open closest relevant element (popup) with jQuery
- How to make JQuery load on top of head tag before everything
- Show and hide element when URL contains certain section of text?
- Customizer add query to preview URL
- why does so many javascript libraries are loaded along with my website?
- Notify user we would like them to clear their cookie. Provide a working button to clear cookies for user
- Modify the href attribute of tag dynamically in WordPress
- Add a jQuery snippet for sepcific user role
- Bootstrap with separate js File
- Call full image url instead of stylsheet directory url in JS for Infinite Scroll Function
- Move jQuery on *top* of footer
- JQuery and Javascript to pan image
- How to blur the_post_thumbnail() via blur.js (jquery)?
- Custom Javascript not working? [closed]
- How to get this jQuary script working?
- Youtube Iframe Api play one video at a time
- How to add JS snippet before closing tag?
- Disable drag metaboxes, create many functions using js not to work!
- How would I get this to work – send to post from thick box
- How to deregister scripts all at once
- Are you sure popup on Contact Form 7 [closed]
- Add jQuery function to media button
- jQuery ajax empty exeption on wordpress
- TypeError: $ is not a function Error using parallax effect in WordPress Template [duplicate]
- Custom jQuery plugin not working
- JS file not loading [closed]
- jQuery append only works if I select html in admin section [closed]
- Javascript Loading Effect to URLs
- Use WordPress Built In Jquery