You are here

function lazy_update_7100 in Lazy-load 7

Update module default values.

File

./lazy.install, line 143
Install, update, and uninstall functions for the Lazy-load module.

Code

function lazy_update_7100() {

  // Get current default values.
  $defaults = variable_get('lazy_filter_defaults');

  // Update it from old string value to new array value.
  $defaults['lazy_filter_alter_tag'] = array(
    'img' => 'img',
    'iframe' => 'iframe',
  );

  // Fix already existing value with new format.
  $lazy_filter_alter_tag = variable_get('lazy_filter_alter_tag');
  switch ($lazy_filter_alter_tag) {
    case 'img':
      variable_set('lazy_filter_alter_tag', array(
        'img' => 'img',
        'iframe' => 0,
      ));
      break;
    case 'iframe':
      variable_set('lazy_filter_alter_tag', array(
        'img' => 0,
        'iframe' => 'iframe',
      ));
      break;
    default:
      variable_set('lazy_filter_alter_tag', $defaults['lazy_filter_alter_tag']);
      break;
  }

  // Add new setting to support image fields.
  $defaults['lazy_filter_image_fields'] = FALSE;

  // Update the defaults with new values.
  variable_set('lazy_filter_defaults', $defaults);
  variable_set('lazy_filter_image_fields', $defaults['lazy_filter_image_fields']);
}