function lazy_update_7103 in Lazy-load 7
Image fields now use display formatter to enable lazy-loading per field.
File
- ./
lazy.install, line 194 - Install, update, and uninstall functions for the Lazy-load module.
Code
function lazy_update_7103() {
$image_fields = variable_get('lazy_filter_image_fields');
if ($image_fields) {
$field_map = field_info_field_map();
foreach ($field_map as $field_name => $field) {
if ($field['type'] === 'image') {
foreach ($field['bundles'] as $entity_type => $bundle) {
$field_instance = field_info_instance($entity_type, $field_name, $bundle[0]);
foreach ($field_instance['display'] as $display_name => $display) {
if ($field_instance['display'][$display_name]['type'] === 'image') {
$field_instance['display'][$display_name]['type'] = 'lazy';
$field_instance['display'][$display_name]['module'] = 'lazy';
field_update_instance($field_instance);
}
}
}
}
}
}
variable_del('lazy_filter_image_fields');
}