ImageField Extended

The ImageField Extended widget adds new form fields to the CCK ImageField widget. All processing, including storage, is done via ImageField. This module simply allows you to easily extend the currently available form fields; alt, description, title, etc, and either let the themers to run their magic, you can use the Custom Formatters module or use the new CCK formatter to display the additional text fields (Help hiding the labels can be found here).

We have used a single multivalue ImageField "Image, with additional fields" field to do all of the following in 3 projects.

  • Header image checkbox, usage has been at both the page and node level.
  • Featured teaser list image flag.
  • Block image of existing page's node.
  • Adding alternative links to the image
  • Extra info to the rendered image. Our main usage is to add new attributes for JScript. We haven't actually added a caption yet!
  • Embedded gallery of selected images

Security note

Remember security if you handle the data yourself. The recommended method to handle the text fields are:

Typical text field (no HTML)

<?php
$no_markup = isset($data['no_markup']['body']) ? check_plain($data['no_markup']['body']) : NULL;
?>

Text field with tags (HTML)

<?php
# You can use filter_xss_admin for TRUSTED users.
$free_text = isset($data['free_text']['body']) ? filter_xss($data['free_text']['body']) : NULL;
?>

Rich text (WYSIWYG)

<?php
$rich_text = '';
if (isset($data['rich_text']) && !empty($data['rich_text']['body'])) {
  $rich_text = check_markup($data['rich_text']['body'], $data['rich_text']['format'], FALSE);
}
?>

Remember that the title from the key|title pairs is also user input. Run this through check_plain() too!

The following pages are used to help demonstrate possible theming uses.

Adding different fields

The way to add any FAPI field is to use the imagefield_extended_widget hook. All you need is a custom module with this function and an info

Extending "Image with node link" function + Example safe uses of the three text fields.

The CCK formatter theming function is "theme_imagefield_formatter_image_nodelink". The following is based on copying the ImageFields base

I18n aware labels

The labels entered for the fields are i18n aware. The translations are required to go into *.po files.

Guide maintainers

alan d.'s picture