WordPress.org

Ready to get started?Download WordPress

Forums

WordPress 3.5 Media Gallery: Create my own Sidebar in Uploader (1 post)

  1. Kriesi81
    Member
    Posted 1 year ago #

    Hey!

    I am currently trying to utilize the new WordPress 3.5 media manager.

    What I want to do is: a user clicks upload button, media manager pops up, user selects image, presses insert, image is then saved to custom field.

    All of that already works, the only thing that I would like to change is to populate the sidebar of the media uploader (were user can add caption, title, select size, etc) with my very own template.

    I already read dozens of tutorials on how to work with backbone but am now a little stuck. here is my some of code so far:

    //defined earlier:
    var frame;
    
    //on click:
    
    if ( file_frame )
    {
    	file_frame.open();
    	return;
    }
    else
    {
        // Create the media frame.
        file_frame  = wp.media(
        {
    	frame:   'select',
    	state:	 'mystate',
    	library:   {type: 'image'},
    	multiple:   false
        });
    
        file_frame.states.add([
    
    	new media.controller.Library({
    		id:         'mystate',
    		title: 'my title',
    		priority:   20,
    		toolbar:    'select',
    		filterable: 'uploaded',
    		library:    media.query( file_frame.options.library ),
    		multiple:   file_frame.options.multiple ? 'reset' : false,
    		editable:   true,
    		displayUserSettings: false,
    		displaySettings: true,
    		allowLocalEdits: true,
    	      //AttachmentView: ?
    
    	}),
        ]);
    
    file_frame.open();
    
    }

    I have also tried registering my own template like this:

    media.view.Attachment.mySidebar = media.view.Settings.AttachmentDisplay.extend(
    {
    	className: 'attachment-display-settings',
    	template:  media.template('avia-choose-size')
    });

    but the problem is: I dont know were to load only this template instead of the original sidebar. passing it as AttachmentView parameter obviously doesnt work since it replaces the whole template and not just the sidebar.

    Anyone with some backbone.js experience who can help?

Topic Closed

This topic has been closed to new replies.

About this Topic