Add upstream
This commit is contained in:
20
wp-content/plugins/shariff/js/shariff-media.js
Normal file
20
wp-content/plugins/shariff/js/shariff-media.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// shariff media upload
|
||||
jQuery(document).ready(function($){
|
||||
$("#shariff-upload-btn").click(function(e) {
|
||||
e.preventDefault();
|
||||
var image = wp.media({
|
||||
title: shariff_media.choose_image,
|
||||
multiple: false
|
||||
}).open()
|
||||
.on("select", function(){
|
||||
// this will return the selected image from the media uploader, the result is an object
|
||||
var uploaded_image = image.state().get("selection").first();
|
||||
// output to the console uploaded_image
|
||||
console.log(uploaded_image);
|
||||
// convert uploaded_image to a JSON object to make accessing it easier
|
||||
var image_url = uploaded_image.toJSON().url;
|
||||
// assign the url value to the input field
|
||||
$("#shariff-image-url").val(image_url);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user