I have an HTML form field that is going to take the url for an image of mine. I have (in a different section of my site) a media library where users can opload and organize their images.
Now I want to be able to open this media library either in a new window (easier for me, but don’t know how I would then populate the form field in the mother window with a script from a new window, method not allowed?) or by reading the media library into a div (more troublesome since I’d have to rewrite much of the media library navigation to not refresh the page but only that div).
I have never done this so I was thinking maybe someone seasoned could give me a hint and start me off in the right direction.
I ended up using jQuery modal dialogue with an Iframe inside, and upon click of an image the input field gets populated and the dialogue is closed.
Some sample code if it can be an inspiration to anyone…
Here is my input box with a browse button
This is somewhere on the form page (hidden by default)
Here is a sample of an image in the mediaLibrary
Here are my functions for initializing, opening and closing the mediaLibrary
And finally the functions for assigning the image and closing the mediaLibrary