How to use default media upload in plugin page

Posted: June 5, 2015 in Uncategorized
Tags: , , , , ,





<a class="ls_test_media" href=";">Click To Attach File</a>

<span style="display:none;" class="txt_show_des">Selected File</span>
<a href="" class="show_fplink" target="_blank"></a>

jQuery Code

jQuery(document).ready(function($) {
//uploading files variable
var custom_file_frame;
var click_btn_obj ;
jQuery(document).on(‘click’, ‘.ls_test_media’, function(event) {
//If the frame already exists, reopen it
if (typeof(custom_file_frame)!==”undefined”) {

//Create WP media frame.
custom_file_frame = ={
//Title of media manager frame
title: “Sample title of WP Media Uploader Frame”,
/*library: {
type: ‘image’
button: {
//Button text
text: “insert File”
//Do not allow multiple files, if you want multiple, set true
multiple: false

//callback for selected image
custom_file_frame.on(‘select’, function() {

var attachment = custom_file_frame.state().get(‘selection’).first().toJSON();
var get_img_path = attachment.url;
// alert(click_btn_obj);
// $(click_btn_obj).siblings(‘.file_result’).html(get_img_path);

/*var selection = custom_file_frame.state().get(‘selection’); {
attachment = attachment.toJSON();
//do something with attachment variable, for example attachment.filename
//attachment.alt – image alt
// – author id
//attachment.dateFormatted – date of image uploaded
//attachment.editLink – edit link of media
//attachment.icon – don’t know WTF?))
// – id of attachment
// – public link of attachment, for example “”″&#8221;
//attachment.mime – mime type, for example image/jpeg”
// – name of attachment file, for example “my-image”
//attachment.status – usual is “inherit”
//attachment.subtype – “jpeg” if is “jpg”
//attachment.type – “image”
//attachment.url – http url of image, for example “;

//Open modal;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s