Bind event on Media gallery elements WordPress
(function ($) { “use strict”; $(function () { var button = $(‘.upload-image’); button.click(function (e) { e.preventDefault(); // If the media frame already exists, reopen it. if (file_frame) { file_frame.open(); return; } var btn = $(this), media = wp.media; // Create the media frame. var file_frame = media.frames.file_frame = media({ title: jQuery(this).data(‘uploader_title’), button: { text: jQuery(this).data(‘uploader_button_text’) … Read more