Configuration

It’s possible to add settings to the function by adding a settings array as a third argument: array( 'title' => 'your-title', 'update' => 'your-update-text', 'field' => 'your-image-field' ). Here are what each setting does…

title – The title text in the upper left corner of the Media Frame. Defaults to ´Image´

update-text – The text on the update button in the lower right corner of the Media Frame. Defaults to ´Update Image´

field – The field name. Change this if you need multiple images in one widget. Defaults to ´image_id´

Note that this plugin will not save your widget data or show your image anywhere on the front-end. It will simply store the field inside the $new_instance array and wait for you to save the widget. Once the widget instance is saved, you will be able to retrieve the image id from the widget data.

FAQ

Installation Instructions

Add the plugin by either downloading the folder and uploading it to the wp-content/plugins directory or install it from the Control Panel using Plugins->Add New.

Activate PCo Image Widget Field from the Plugins menu using Plugins->Installed Plugins.

Configuration

It’s possible to add settings to the function by adding a settings array as a third argument: array( 'title' => 'your-title', 'update' => 'your-update-text', 'field' => 'your-image-field' ). Here are what each setting does…

title – The title text in the upper left corner of the Media Frame. Defaults to ´Image´

update-text – The text on the update button in the lower right corner of the Media Frame. Defaults to ´Update Image´

field – The field name. Change this if you need multiple images in one widget. Defaults to ´image_id´

Note that this plugin will not save your widget data or show your image anywhere on the front-end. It will simply store the field inside the $new_instance array and wait for you to save the widget. Once the widget instance is saved, you will be able to retrieve the image id from the widget data.

Will this work for WordPress versions earlier than 3.5.0?

No. This plugin was build to make the Media Frame more useful.
Older versions of WordPress will have to use thickbox instead. You can use the Widget Image Field plugin instead, but it’s recommended that you update your WordPress installation instead.

Will this automatically add an image field to my widget when I install it?

No. This plugin just creates the building blocks.
You will have to manually add the function pco_image_field( $this, $instance ) inside your widget.

This plugin was build to let developers easily add an image field to their widgets. If you have a developer available this will be an easy task.

I have added the function but it returns warnings and kills my script. Eh?

Make sure the plugin has been activated. Adding a function that doesn’t exists will produce a PHP warning and kill the script. To prevent these errors you can use a function_exists before calling pco_image_field().

What if I don’t declare any fields to the settings array?

You don’t have to define the settings array. The default field is image_id, and is recommended for simplicity.