This is my input markup:
<div class="button-primary" id="fileToUpload">Upload</div>
This is js:
jQuery( \'#fileToUpload\' ).click( function()
{
var custom_uploader = wp.media
({
title: \'Select\',
button: {
text: \'Select\'
},
multiple: false // Set this to true to allow multiple files to be selected.
})
.on( \'select\', function()
{
var attachment = custom_uploader.state().get( \'selection\' ).first().toJSON();
jQuery( \'#previewImage\' ).attr( \'src\', attachment.url );
jQuery( \'.custom_media_url\' ).val( attachment.url );
jQuery( \'.custom_media_id\' ).val( attachment.id );
})
.open();
});
我想将文件类型限制为
jpg,jpeg and png
. 我怎样才能做到这一点?