You are here

function custom_formatters_insert_content in Custom Formatters 7.2

Same name and namespace in other branches
  1. 6 includes/insert.inc \custom_formatters_insert_content()

Implements hook_insert_content().

File

includes/insert.inc, line 35
Insert module integration.

Code

function custom_formatters_insert_content($item, $style) {
  $menu_item = menu_get_item();
  $form_build_id = end($menu_item['page_arguments']);
  if (is_string($form_build_id)) {
    $form_state = array();
    $form = form_get_cache($form_build_id, $form_state);
    $obj_type = $form['#entity_type'];
    $object = $form["#{$obj_type}"];
    $field = field_info_field($menu_item['page_arguments'][0]);
    $instance = field_info_instance($obj_type, $field['field_name'], $form['#bundle']);
    $langcode = field_language($obj_type, $object, $field['field_name']);
    $items = array(
      (array) file_load($item['fid']),
    );
    $display = $instance['display']['default'];
    $formatter = custom_formatters_crud_load(drupal_substr($style['name'], 18));
    $display['#cf_options'] = array(
      '#contextual_links' => FALSE,
    );
    $element = custom_formatters_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display, $formatter);
    return render($element);
  }
  return FALSE;
}