File: /var/www/html/WPSassoon/wp-content/themes/sassoon/js/deal-meta.js
jQuery(document).ready(function ($) {
// Upload Logo
$(document).on('click', '.upload-logo', function (e) {
e.preventDefault();
var button = $(this);
var target = button.data('target');
var imageField = $('#' + target);
var preview = $('#' + target + '_preview');
// Create a NEW uploader every time
var custom_uploader = wp.media({
title: 'Select Logo',
button: { text: 'Use this logo' },
multiple: false
}).on('select', function () {
var attachment = custom_uploader.state().get('selection').first().toJSON();
imageField.val(attachment.url);
preview.attr('src', attachment.url).show();
}).open();
});
// Remove Logo
$(document).on('click', '.remove-logo', function (e) {
e.preventDefault();
var target = $(this).data('target');
$('#' + target).val('');
$('#' + target + '_preview').attr('src', '').hide();
});
});