Guest User

Bug Profund Plugin

a guest
Sep 7th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.    $(document).on("click", ".upload_image_button", function (e) {
  3.       e.preventDefault();
  4.       var $button = $(this);
  5.       // Create the media frame.
  6.       var file_frame = (wp.media.frames.file_frame = wp.media({
  7.          title: "Select or upload image",
  8.          library: {
  9.             // remove these to show all
  10.             type: "image", // specific mime
  11.          },
  12.          button: {
  13.             text: "Select",
  14.          },
  15.          multiple: false, // Set to true to allow multiple files to be selected
  16.       }));
  17.  
  18.       // When an image is selected, run a callback.
  19.       file_frame.on("select", function () {
  20.          // We set multiple to false so only get one image from the uploader
  21.          var attachment = file_frame.state().get("selection").first().toJSON();
  22.          $button.parent().siblings(".author_image_url").val(attachment.url);
  23.          $button
  24.             .parents(".image_upload_part")
  25.             .find(".dm_image")
  26.             .attr("src", attachment.url);
  27.       });
  28.  
  29.       // Finally, open the modal
  30.       file_frame.open();
  31.    });
  32. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment