Error message

The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.

Retrieve CCK Filefield Imagefield Default Image Path

Category: 

Here is how to get a Drupal 6 CCK Filefield Imagefield default image path:

function tf_cck_nodefield_widget_settings ($field_name) {
  $sql = " SELECT widget_settings FROM {content_node_field_instance} WHERE field_name = '%s' ";
  return unserialize(db_result(db_query($sql,$field_name)));
}

// example usage
$my_imagefield_widget_settings = tf_cck_nodefield_widget_settings("field_my_image");
$img_src = $my_imagefield_widget_settings['default_image']['filepath'];
print theme_image($img_src,"","");

This will also work for many other CCK field widget settings, as the function above just returns an array of the unserialized string that represents the widget settings.

Add new comment