Commit 4ec40014 authored by osman's avatar osman

Issue #3050003: Decrease number of calls for `lazy.settings` config

parent 5220848e
......@@ -36,21 +36,20 @@ function lazy_help($route_name, RouteMatchInterface $route_match) {
* Implements template_preprocess_field().
*/
function lazy_preprocess_field(&$variables) {
$config = \Drupal::config('lazy.settings')->get();
$pages = $config['disabled_paths'];
$path_matches = lazy_disabled_by_path($pages);
$element = $variables['element'];
if (!$path_matches && $element['#field_type'] === 'image') {
if ($element['#field_type'] === 'image') {
$config = \Drupal::config('lazy.settings')->get();
$pages = $config['disabled_paths'];
$path_matches = lazy_disabled_by_path($pages);
if (!$path_matches) {
$entity = $element['#object'];
$entity_type = $entity->getEntityTypeId();
$bundle = $entity->bundle();
$view_mode = $element['#view_mode'];
$field_name = $element['#field_name'];
$field_name = $element['#field_name'];
$render_display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode);
$field_display = $render_display->getComponent($field_name);
$image_fields = [];
$field_display = $render_display->getComponent($field_name);
$image_fields = [];
if (isset($field_display['third_party_settings']['lazy']) && $field_display['third_party_settings']['lazy']['lazy_image']) {
foreach ($variables['items'] as $key => $item) {
......@@ -62,6 +61,7 @@ function lazy_preprocess_field(&$variables) {
lazy_settings_update($image_fields);
}
}
}
/**
......
  • Hi there, I have a quick question. Can you tell me why do you need to call lazy_settings_update($image_fields); on the preprocess field hook?

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment