• I’m reaching out for help after days of searching; I need users to be able to upload an image to be attached to a custom post. I find many hacks and descriptions about how to customize on admin page but none for the front-end. I was hoping to be able to tweak this code, but I think i get stuck on the wp.media bit that only runs in the admin pages.
    `
    function open_media_window() {
    if (this.window === undefined) {
    this.window = wp.media({
    title: ‘Insert a media’,
    library: {type: ‘image’},
    multiple: false,
    button: {text: ‘Insert’}
    });

    var self = this; // Needed to retrieve our variable in the anonymous function below
    this.window.on(‘select’, function() {
    var first = self.window.state().get(‘selection’).first().toJSON();
    wp.media.editor.insert(‘[myshortcode id=”‘ + first.id + ‘”]’);
    });
    }

    this.window.open();
    return false;
    }

    Source: http://www.sitepoint.com/adding-a-media-button-to-the-content-editor/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Front-end upload button’ is closed to new replies.