Advanced search  


cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.

Pages: [1]   Go Down

Author Topic: HowTo: spare server resources  (Read 2581 times)

0 Members and 1 Guest are viewing this topic.


  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 251
    • Flavio's page
HowTo: spare server resources
« on: March 14, 2015, 12:34:40 am »

If you have jquery on the page cpmfetch outputs the pics to, you may want to consider loading the images ONLY whenever an user scrolls to them.
This may prove useful if you choose to load intermediate or even full size pics.
You can use jquery unveil ( ):
Code: [Select]
<script type="text/javascript">
(function(e){e.fn.unveil=function(k,d){function c(){g=b.filter(function(){var a=e(this);if(!":hidden")){var b=f.scrollTop(),d=b+f.height(),c=a.offset().top;return c+a.height()>=b-h&&c<=d+h}}).trigger("unveil");b=b.not(g)}var f=e(window),h=k||0,l=1<window.devicePixelRatio?"data-src-retina":"data-src",b=this,g;"unveil",function(){var a=this.getAttribute(l);if(a=a||this.getAttribute("data-src"))this.setAttribute("src",a),"function"===typeof d&&});f.on("scroll.unveil resize.unveil lookup.unveil", c);c();return this}})(window.jQuery||window.Zepto);
$(function() {

Then, open cpmfetch.php and edit line 1551:
Code: [Select]
$htmlOut .= '<img src="/img/ajax-loader.gif" data-src="' . $imagefile . '"';
...where ajax-loader.gif is whatever loading spinning ball you prefer.

You can see the result on my homepage ( )
Pages: [1]   Go Up

Page created in 0.016 seconds with 21 queries.