diff --git a/filter.php b/filter.php index fa56398..2c5bef0 100644 --- a/filter.php +++ b/filter.php @@ -200,7 +200,13 @@ private function process_img_tag(array $match) { $imageinfo = (object) $file->get_imageinfo(); if ($imageinfo->width <= $maxwidth && !local::file_is_public($file->get_contenthash())) { - return $match[0]; + if (empty($this->config->lovsmallimage) || $this->config->loadonvisible == 999) { + return $match[0]; + } else { + // Apply load on visible. + $url = new \moodle_url($CFG->wwwroot . '/' . $match[3]); + return $this->apply_loadonvisible($match, $file, $url, $url); + } } $optimisedpath = local::get_optimised_path($file, $match[3]); diff --git a/lang/en/filter_imageopt.php b/lang/en/filter_imageopt.php index 9327735..a946b1c 100644 --- a/lang/en/filter_imageopt.php +++ b/lang/en/filter_imageopt.php @@ -29,6 +29,8 @@ $string['donotloadonvisible'] = 'No placeholding, load immediately'; $string['loadonvisibilityall'] = 'All images'; $string['loadonvisibilityafter'] = 'After {$a} image(s)'; +$string['lovsmallimage'] = 'Load when visible for small images'; +$string['lovsmallimagedesc'] = 'Apply "Load when visible" for images which are smaller than "Maximum image width"'; $string['widthattribute'] = 'Image width attribute'; $string['widthattributedesc'] = 'How should existing image width attributes be dealt with'; $string['widthattpreserve'] = 'Preserve user width attributes in all cases'; diff --git a/settings.php b/settings.php index 83ffc3d..7d9b2a2 100644 --- a/settings.php +++ b/settings.php @@ -48,6 +48,13 @@ $settings->add(new admin_setting_configselect('filter_imageopt/loadonvisible', get_string('loadonvisible', 'filter_imageopt'), get_string('loadonvisibledesc', 'filter_imageopt'), 5, $choices)); + $settings->add(new admin_setting_configcheckbox( + 'filter_imageopt/lovsmallimage', + get_string('lovsmallimage', 'filter_imageopt'), + get_string('lovsmallimagedesc', 'filter_imageopt'), + 0 + )); + $choices = [ local::WIDTH_ATT_PRESERVE_MAX => get_string('widthattpreserveltmax', 'filter_imageopt'), local::WIDTH_ATT_PRESERVE => get_string('widthattpreserve', 'filter_imageopt')