diff options
author | Florian Pritz <bluewind@xinu.at> | 2016-07-21 19:01:47 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2016-07-21 19:01:47 +0200 |
commit | 0db79529d129dd4fe1e9b7bf823e07510c806bd4 (patch) | |
tree | 758308bb93f37f84641032c96d88f6d21a443bec | |
parent | 6d6232b8652d980621a797b0b3f0178c8f14630d (diff) |
history: Disable lazy loading for the first 42 thumbnails
This speeds up the initial rendering of the page. For a long history
(> ~1000 items) the lazyloading JS creates a noticeable delay (>500ms)
depending on the cpu power of the machine.
Disable lazy loading for the first items so that these are loaded
normally by the browser parallel to the scripts execution.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | application/views/file/fragments/thumbnail.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/application/views/file/fragments/thumbnail.php b/application/views/file/fragments/thumbnail.php index 8bb7f6aea..82d0743fb 100644 --- a/application/views/file/fragments/thumbnail.php +++ b/application/views/file/fragments/thumbnail.php @@ -5,9 +5,12 @@ $base_url = site_url(); if (substr($base_url, -1) !== "/") { $base_url .= "/"; } +$counter = 0; ?> <div class="upload_thumbnails"><!-- - <?php foreach($items as $key => $item): ?> + <?php foreach($items as $key => $item): + $counter++; + ?> --><a <?php if (strpos($item["mimetype"], "image/") === 0) {?>rel="gallery" class="colorbox"<?php } ?> data-orientation="<?php echo $item["orientation"]; ?>" @@ -15,9 +18,16 @@ if (substr($base_url, -1) !== "/") { title="<?php echo htmlentities($item["filename"], ENT_QUOTES); ?>" data-content="<?php echo htmlentities($item["tooltip"], ENT_QUOTES); ?>" data-id="<?php echo $item["id"]; ?>"><!-- - --><img class="thumb lazyload" - data-original="<?php echo $base_url."file/thumbnail/".$item["id"]; ?>" - ><!-- + --><?php if ($counter > 42) { + ?><img + class="thumb lazyload" + data-original="<?php echo $base_url."file/thumbnail/".$item["id"]; ?>" + ><?php + } else { + ?><img + class="thumb" + src="<?php echo $base_url."file/thumbnail/".$item["id"]; ?>"><?php + } ?><!-- --><noscript><img class="thumb" src="<?php echo $base_url."file/thumbnail/".$item["id"]; ?>"></noscript></a><!-- <?php endforeach; ?> --> |