Wordpress Plugin Development: Using Media Library
When porting jquery-refolio over to wordpress one of the things I wanted to do was tie into wordpress’ Media Library. This makes it extremely easy to re-use images already in wordpress and it would mean I didn’t have to re-invent the wheel. Shockingly enough I couldn’t find it documented anywhere in Wordpress’ officials documentation and even a few quick googles came up empty.
I eventually stumbled upon the answer and I was suprised at how easy it was. Hopefully this will help someone in the future trying to do the same thing.
You must then register a callback as such (the name is important and must be registered in the global namespace):
1 2 3 4 5 6 7 8 9 10 11
The callback will be invoked when the user has selected an image to insert. Here is a sample HTML snippet passed back to the callback function:
1 2 3