I have a word press theme with a theme options dialog
I’d like to add a feature to upload a logo via the theme options page and then display it on the front end in the header as the logo. How would I do this. I would like to use the wordpress media uploaded, but if this is not possible or an alternative is available Id appreciate that also
It is possible to use the built in WordPress Media Upload in your theme functions. I’ve incorporated it successfully into many themes, and in a variety of different uses.
Below is a simple version (I’ve got another version that supports multiple image upload fields in a single page).
In a javascript file (save as media_upload.js in your theme directory):
In your theme’s functions.php file, you have to enqueue the necessary scripts (including the one above) by creating a function and using the WP hooks to call the function on admin int:
And finally, where you want the media upload input fields and preview to appear, use the following html:
It’s up to you to provide the css to style it up to look good.
Also please note that this should only ever be done on the admin side. You cannot trust the average visitor to upload anything to your site.
I found a way to pass the url from the WP Media Uploader to a text box, then saved the id information from the text field. The input fields:
And for my jQuery:
The name field from the Button is the same as the ID from the Text box – links the two and passes the information easily. The rest is standard in the functions.php to enable your scripting
I am not a wordpress user/developer, but just as an idea, would it be possible to write your own php page to upload this file to the correct location and embed this page as an iFrame in your dialog?
It appears in WordPress 3 this isn’t possible. WordPress loads up the media-upload.php file in an iframe, and the form which usually contains the delete and insert into post and use as post thumbnail, is get_media_item() in media.php at line 1156.
Unfortunately while one can pull up the media uploader, it cant be modified via hooks and filters to insert the extra buttons or links without modifying the core wordpress files.