blazyloading-2.0.0/blazyloading.module

blazyloading.module
<?php

/**
 * @file
 * Contains blazyloading.module functionality.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function blazyloading_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the multi_site_config module.
    case 'help.page.blazyloading':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Blazyloading Config Page Here') . '</p>';
      $output .= '<p>' . t('/admin/config/services/blazyloading/configuration') . '</p>';
      $output .= '<p>' . t('In the admin configuration below is some point for enable the CDN Server setting.');
      $output .= '<ul>';
      $output .= '<li>' . t('Add the URL of CDN Server like below<br>https://res.cloudinary.com/project_name/image/fetch/c_limit,w_cdn_server_width,h_cdn_server_height/source_image_url') . '</li>';
      $output .= '<li>' . t('Here is "cdn_server_height" parameter will replace by height of image.') . '</li>';
      $output .= '<li>' . t('Here source_image_url will replace by the original image url if URL contains the either https or http.') . '</li>';
      $output .= '</ul></p>';
      return $output;

    default:
  }
}

/**
 * Implements hook_page_attachments().
 */
function blazyloading_page_attachments(array &$page) {
  $config = \Drupal::config('blazyloading_configuration.settings');
  $blazy_loading_status = $config->get('blazy_loading_status');
  $cdn_server_status = $config->get('cdn_server_status');
  $cdn_server_url = $config->get('cdn_server_url');
  $page['#attached']['drupalSettings']['cdn_server_status'] = FALSE;

  if ($blazy_loading_status) {
    $page['#attached']['library'][] = 'blazyloading/blazyloading.lazyLoading';
  }
  if ($cdn_server_status) {
    $page['#attached']['drupalSettings']['cdn_server_status'] = TRUE;
    $page['#attached']['drupalSettings']['cdn_server_url'] = $cdn_server_url;
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc