I'm building a custom dashboard and I'd like to add a feature which allows a user to upload an image.

However, by calling wp.media() (with a title, button & multiple args) javascript throws an error this.activateMode is not a function - Shouldn't it pop-up the media view/modal?

For clarifying, I'm calling wp.media in a button's click event callback function. And yes, I load all the necessary styles/scripts by calling wp_enqueue_media(); and I do see them in the page's source code. And wp.media is not undefined, so it is loaded.

WordPress has very limited dev docs overall, so I'm not sure what dependencies wp.media has/needs in order to work properly. I dove into the source code but couldn't find an answer. Seems like it should work properly by simply calling the wp.media

So.... What I'm missing?

Sure I could build my own modal for media CRUD actions by using WP REST API but it would be a time-consuming process.

  • Do you have a live version to take a look at? Have you checked that you're load order is correct?
    – Steven
    Jun 4, 2019 at 6:53

1 Answer 1


To solve " TypeError: this.activateMode is not a function " error, add lodash as an external in your webpack config file.

externals: {
   'lodash': 'lodash'
  • This needs more signal for TypeError: this.activateMode is not a function
    – luckyape
    Nov 12, 2020 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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