You are here

function sharemessage_update_7001 in Share Message 7

Add the video url field.

File

./sharemessage.install, line 308
Install hooks for sharemessage module.

Code

function sharemessage_update_7001() {
  $url_field_instance = field_info_instance('sharemessage', 'sharemessage_url', 'sharemessage');
  if (!field_info_field('sharemessage_video_url')) {
    $field = array(
      'field_name' => 'sharemessage_video_url',
      'type' => 'text',
      'locked' => TRUE,
    );
    field_create_field($field);

    // Create the instance on the bundle.
    $instance = array(
      'field_name' => 'sharemessage_video_url',
      'entity_type' => 'sharemessage',
      'label' => 'Video URL',
      'description' => 'The image URL that will be used for sharing. If a video URL is set, the image will be used as a thumbnail for the video.',
      'bundle' => 'sharemessage',
      'widget' => array(
        'type' => 'text_textfield',
        'weight' => $url_field_instance['widget']['weight'],
      ),
      'display' => array(
        'default' => array(
          'type' => 'hidden',
        ),
      ),
    );
    field_create_instance($instance);
  }

  // Move the url field below the video field.
  $url_field_instance['widget']['weight']++;
  field_update_instance($url_field_instance);
}