Extending WP Media Modal
-
Hi – I am trying to customize the WP media modal (wp.media.view.Attachment.Details) following the basic steps outlined here: https://annaschneider.me/blog/adding-custom-content-with-javascript-to-wordpress-media-modals/
My JS code that does the customization to the template is hooked up to the DOMContentLoaded event, but does not seem to be executing. If I wait around 500ms after DOMContentLoaded to extend the view template, then it seems to work. I’m wondering if there is another or better event to be listening for in order to do the customization? Something like an event when Backbone.js is ready?
function extendMediaTemplate() { wp.media.view.Attachment.Details = wp.media.view.Attachment.Details.extend({ template: function (view) { console.log("HERE"); // This is not getting called unless I wait 0.5 sec // My code here... } });
Curious if anyone has successfully customized one of these media modals before… ??
- The topic ‘Extending WP Media Modal’ is closed to new replies.