Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Media Manager once again. This time I'm looking for a simple hack/hook/filter to change default "Attachment Display Settings" from media manager. The option is "Link To" that is default set to "Media File" and I would like to force it for all users to be default set to "none".

Media Manager Screen

If there is no way to do it with hook/filter (media-template.php lines 282 - 306) - is there a way to attach jQuery file to Media Manager and use it to force change option after Media Manager is loaded?

share|improve this question
As far as I can understand, the only way to do it is to use jQuery... media-template.php lines 282 - 306 - sadly "selected" is hardcoded there with no hook/filter/anything to do it. So any ideas about adding aditional jQuery file to Media Manager with changing default option would be also a good (if not only) solution. –  Marcin Bobowski Feb 18 '13 at 12:25
add comment

1 Answer

up vote 2 down vote accepted

You can do what you want by overriding appropriate Backbone view, which is responsible for rendering attachments display settings form.


add_action( 'load-post.php', 'wpse8170_media_popup_init' );
add_action( 'load-post-new.php', 'wpse8170_media_popup_init' );
function wpse8170_media_popup_init() {
    wp_enqueue_script( 'wpse8170-media-manager', plugins_url( '/js/media.js', __FILE__ ), array( 'media-editor' ) );


(function() {
    var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay;
    wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({
        render: function() {
            _AttachmentDisplay.prototype.render.apply(this, arguments);
            this.model.set('link', 'none');
share|improve this answer
This is almost working solution... But when You insert image into post, it still gets inserted with anchor around it :(. Perhaps some kind of "force change" of this parameter (I dont know backbone at all :( ) would do the trick? –  Marcin Bobowski Feb 19 '13 at 10:32
@MarcinBobowski I have updated my JS snippet and it works fine now. Check it out! –  Eugene Manuilov Feb 19 '13 at 10:45
Yep, this is it :). I was so close to answer - model.set was the only thing that Was missing in my tries (updateLinkTo i have already fugured out). Thanks :) –  Marcin Bobowski Feb 19 '13 at 12:38
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.