Commit 676a3893 authored by osman's avatar osman

Issue #3056589: Add colorbox support

parent efa75785
......@@ -32,6 +32,18 @@ function lazy_help($route_name, RouteMatchInterface $route_match) {
return NULL;
}
/**
* Returns supported field-types.
*
* @return array
*/
function lazy_field_types() {
return [
'colorbox',
'image',
];
}
/**
* Implements template_preprocess_field().
*/
......@@ -141,7 +153,7 @@ function lazy_is_enabled() {
function lazy_field_formatter_third_party_settings_form($plugin) {
$element = [];
if ($plugin->getPluginId() === 'image') {
if (in_array($plugin->getPluginId(), lazy_field_types(), TRUE)) {
$element['lazy_image'] = [
'#type' => 'checkbox',
'#title' => t('Enable lazy-loading'),
......@@ -164,7 +176,7 @@ function lazy_form_entity_view_display_edit_form_alter(&$form, FormStateInterfac
if ($fields = $form_state->getValue('fields')) {
foreach ($fields as $field_name => $field) {
if (
($field['type'] === 'image')
in_array($field['type'], lazy_field_types(), TRUE)
&& isset($field['settings_edit_form']['third_party_settings']['lazy']['lazy_image'])
) {
$route_match = \Drupal::service('current_route_match');
......@@ -182,7 +194,7 @@ function lazy_form_entity_view_display_edit_form_alter(&$form, FormStateInterfac
*/
function lazy_field_formatter_settings_summary_alter(&$summary, $context) {
if (
($context['formatter']->getPluginId() === 'image')
in_array($context['formatter']->getPluginId(), lazy_field_types(), TRUE)
&& $context['formatter']->getThirdPartySetting('lazy', 'lazy_image', FALSE)
) {
$summary[] = t('Lazy-loading enabled');
......
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