Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    How to use WordPress Media Upload in plugin / theme

    Using the WordPress media library in your own plugin/theme will save you a bunch of time. This blog will provide an example of how to use the Media Library in a plugin/theme environment.

    When using, there are a few things that we are interested. The first one is how to define the media frame.


    This article will just show the code snippets that you need to use in order to get everything to work. The rest will be up to you to incorporate into your plugin/theme.


    We need some html tags in order to select media file and these are:-

    • A text input where we will put the URL of the file we select.
    • A button that will activate the WordPress media library.
    • Finally a submit button so that you can do something with the URL.

    The second thing that we are interested in is how to capture the event when we have selected the image(s) and clicked on the Select button.

    JavaScript Code Example


    Still have any issue feel free to add a ticket and let us know your views to make the code better

    Thanks for Your Time! Have a Good Day!

    . . .

    Comments (2)

    Add Your Comment

  • Luděk Černý
    Great article, saved me from a headache! 🙂
    • Archana Tiwari
      Hello There,
      Thanks for the appreciation.
      In case of further queries please mail us at
      With Regards,
      Webkul Team
  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again

    Table of Content

    Hide Index