Files
wordpress-preseed/wp-content/plugins/shariff/js/shariff-media.js
2019-09-11 19:08:46 +02:00

21 lines
706 B
JavaScript

// 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);
});
});
});