| Server IP : 60.247.133.247 / Your IP : 216.73.217.108 Web Server : Apache System : Linux ebs-119054 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64 User : goodwill ( 65985) PHP Version : 8.2.20 Disable Function : link,symlink,passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server,pcntl_fork,pcntl_rfork MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/wwwroot/goodwill/wwwroot/wp-content/plugins/custom-login-logo/assets/js/ |
Upload File : |
jQuery(document).ready(function ($) {
const uploadSection = $('.upload');
if (!uploadSection.length) {
return;
}
let mediaFrame;
uploadSection.each(function () {
const section = $(this);
const textInput = section.find('.text-upload');
const button = section.find('.button-upload');
const preview = section.find('.preview-upload');
button.on('click', function (e) {
e.preventDefault();
// If media frame already exists, reopen it
if (mediaFrame) {
mediaFrame.open();
return;
}
// Create media frame
mediaFrame = wp.media({
title: 'Select or Upload Logo',
button: {
text: 'Use this image',
},
multiple: false,
});
mediaFrame.on('select', function () {
const attachment = mediaFrame.state().get('selection').first().toJSON();
textInput.val(attachment.url).trigger('change');
preview.attr('src', attachment.url).show();
});
mediaFrame.open();
});
textInput.on('change', function () {
const url = $(this).val();
preview.attr('src', url).show();
});
});
});