jQuery(document).ready(function ($) {
    $('.litemamo-upload').on('click', function (e) {
        e.preventDefault();

        var button = $(this);
        var target = $(button.data('target'));

        // WordPress Media Uploader
        var frame = wp.media({
            title: 'Select or Upload Image',
            button: { text: 'Use this image' },
            multiple: false
        });

        frame.on('select', function () {
            var attachment = frame.state().get('selection').first().toJSON();
            target.val(attachment.url);
        });

        frame.open();
    });
});
