You are here

function paragraphs_pack_add_field_image in Paragraphs pack 7

Adds image field to a paragraph bundle.

Parameters

string $bundle: A paragraph type machine_name.

string $field_label: A label of the field.

array $settings: An instance settings that overrides default settings. Default settings are commented in this function, so all the options can be found there.

Return value

array An items field instance.

1 call to paragraphs_pack_add_field_image()
paragraphs_pack_juicebox_install in modules/paragraphs_pack_juicebox/paragraphs_pack_juicebox.install
Implements hook_install().

File

includes/paragraphs_pack.fields_crud.inc, line 345
Fields CRUD functions.

Code

function paragraphs_pack_add_field_image($bundle, $field_label, $settings = array()) {
  $field = paragraphs_pack_get_field_image();

  // Default settings with all possible options.
  $settings_default = array();

  // Add default settings if some options are missing
  $settings += $settings_default;
  $instance = _paragraphs_pack_add_field(array(
    'field_name' => $field['field_name'],
    'entity_type' => PP_PARAGRAPH_TYPE,
    'bundle' => $bundle,
    'label' => $field_label,
    'required' => TRUE,
    'settings' => $settings,
  ));
  return $instance;
}