wp.media – Modifying Attachment Display Settings
-
I’m developing a plugin and I am trying to add a new option to the “Link To” select menu to link the inserted image to a specific url and also include a css class on the link. So far no luck with the wp.media codebase (really wish there was better documentation :( )
var origAttachmentDetails = media.view.Settings.AttachmentDisplay; media.view.Settings.AttachmentDisplay = origAttachmentDetails.extend({ initialize: function() { origAttachmentDetails.prototype.initialize.apply( this, arguments ); this.on( 'ready', this.linkTo ); this.listenTo( this, 'post-render', function() { alert('rr') }) this.listenTo( this.model, 'change:link', this.setLink ); }, linkTo: function(){ var option = $('<option value="custom-class">Custom Option</option>'); if(this.model.get('linkClassName') == 'custom-class') { option.attr('selected', 'selected'); } this.$('select[data-setting="link"]').prepend(option); }, setLink: function(){ if (this.model.get('link') == 'custom-class') { var value = this.options.attachment.get('url'); this.$('input.link-to-custom').val(value); //how do I set the property on the image when inserted???? } } });Any help is greatly appreciated – Thanks!
The blog I need help with is: (visible only to logged in users)
- The topic ‘wp.media – Modifying Attachment Display Settings’ is closed to new replies.