Reputation: 834
I have made a custom form in wordpress in the admin panel on my plugin settings page. I have an input field that I wont to hold the URL for an image that will be selected via the Wordpress Image Manager.
I am not really sure how to go about this. Is there a way to call the image manager and connect the return value to my custom input field? I do not need to upload any images ( I assume if the user wants to it will be possible after the image manager is loaded?), I just need to popup the image manager, select an image, and return the URL to be put in the input box.
Upvotes: 0
Views: 1193
Reputation: 1793
Sounds like you made your "Theme options"? If so you can call on the option with something like this.
You can call this variable at the top of the page
<?php
//get theme options
$options = get_option( 'theme_settings' );
?>
And to echo <?php echo ($options['image_url']); ?>
I now use an options framework called SMOF this is very handy and adds a great theme options page. https://github.com/sy4mil/Options-Framework
Upvotes: 1
Reputation: 834
Ok I found the solution for wordpress 3.5 and later:
First you need to call the function wp_enqueue_media() function in your plugin when you are loading your scripts.
Then you can follow the instruction found here: http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/
This worked well for me!
Upvotes: 0