2

I know this question is very similar to this previously asked question; however, I was wondering if there was a more up-to-date/official way to refresh content programmatically in the WordPress admin media manager.

In my specific instance, I'm trying to integrate the Getty Images plugin with a select attachment modal (e.g., Featured Image).

Currently, I've been able to successfully extend a few methods of media.view.MediaFrame.Select to integrate the plugin and select the attachments:

var media = wp.media;

var parentCoreSelect = media.view.MediaFrame.Select;

media.view.MediaFrame.Select = media.view.MediaFrame.Select.extend({

  // REFRESH CONTENT
  browseContent: function(){
    var state   = this.state()
      , library = state.get('library');

    /**** relevant part, adapted from other question ****/
    library.props.set({ '__ignore_force_update': (+ new Date()) });
    /**** relevant part, adapted from other question ****/

    parentCoreSelect.prototype.browseContent.apply(this, arguments);
  },

  // add getty plugin functionality to select attachment modal
  createStates: function(){
    parentCoreSelect.prototype.createStates.apply(this, arguments);
    this.states.add([
      // new getty controller -- omitted for brevity
    ]);
  }

});

This works to refresh the attachment content and I can see freshly downloaded images from Getty once I toggle back to Select an Image > Media Gallery. At this point, however, when I upload files via the Upload Files tab in the same modal, the upload occurs successfully but the attachment content in the Media Gallery is not updated (i.e., new upload is not visible to end user, although meta data is displayed in the right panel).

Is there a better way to do this so I can maintain the normal upload functionality, where the fresh upload is shown and selected?

Thanks!

  • 2
    Hello! I am the original author of this plugin, and I would also like to work on figuring out why this piece doesn't work. It's also related to another plugin I'm working on. Wouldn't some official documentation be nice?? – Bendoh Feb 12 '15 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.