Wiki source code of Adding blazy to the Mos-Eisley Gallery
Last modified by Normann P. Nielsen on 2014/07/16 09:01
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | Due to some serious performance when rendering images for a complete year - like on [[Familiebilleder 2013>>Main.familiebilleder.familiebilleder-2013]] - Rendering +1000 thumbnails, this takes a long time. |
| 2 | |||
| 3 | So I kind of tripped over the blazy script - [[http://dinbror.dk/blog/blazy/]] - which is described as: | ||
| 4 | |||
| 5 | {{success}}bLazy is a lightweight script for lazy loading and multi-serving images. It’s written in pure JavaScript why it doesn’t depend on 3rd-party libraries such as jQuery. bLazy works on all modern browsers, including on IE7+.{{/success}} | ||
| 6 | |||
| 7 | |||
| 8 | |||
| 9 | This is pretty easy to implement, there are 3 parts: | ||
| 10 | |||
| 11 | = Loading the js file = | ||
| 12 | |||
| 13 | Using a techinque like [[Installing Javascript libraries or frameworks in Confluence>>Main.atlassian.atlassian-confluence.mos-eisley-gallery.installing-javascript-libraries-or-frameworks-in-confluence]] - be sure the js file is loaded (this can be checked by viewing source, find the js include and test the complete URL) | ||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | = Initialize in the Custom HTML = | ||
| 18 | |||
| 19 | Under Custom HTML in the Administration, under "At beginning of the BODY", add | ||
| 20 | |||
| 21 | |||
| 22 | {{code}} | ||
| 23 | <script type="text/javascript"> | ||
| 24 | jQuery(function($){ | ||
| 25 | // Initialize | ||
| 26 | var bLazy = new Blazy({ | ||
| 27 | selector: 'img' // all images | ||
| 28 | }); | ||
| 29 | }); | ||
| 30 | </script> | ||
| 31 | {{/code}} | ||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | = Change the me-image Macro = | ||
| 36 | |||
| 37 | To get the hook and thumbnails, the [[User Macro: me-image - Image lightbox with Flare>>Main.atlassian.atlassian-confluence.mos-eisley-gallery.user-macro-me-image-image-lightbox-with-flare]] (or similar) has to be changed a bit (refer to [[http://dinbror.dk/blog/blazy/]]): | ||
| 38 | |||
| 39 | |||
| 40 | {{code language="Midnight"}} | ||
| 41 | ## @param path:title=Status|type=string|required=true|desc=File Path | ||
| 42 | ## @param image:title=Status|type=string|required=true|desc=Image Name | ||
| 43 | ## @param group:title=Status|type=string|required=true|desc=Group | ||
| 44 | ## @param thumbsize:title=Thumbsize|type=string|required=false|desc=Thumbnail Size | ||
| 45 | ## @param displaysize:title=Displaysize|type=string|required=false|desc=Display Size | ||
| 46 | |||
| 47 | ## Default Thumb and Display Sizes: | ||
| 48 | #set($ThumbSizeDefault=200) | ||
| 49 | #set($DisplaySizeDefault=800) | ||
| 50 | |||
| 51 | #if (${paramthumbsize} != "" ) | ||
| 52 | #set($ThumbSizeDefault=${paramthumbsize}) | ||
| 53 | #end | ||
| 54 | |||
| 55 | #if (${paramdisplaysize} != "" ) | ||
| 56 | #set($DisplaySizeDefault=${paramdisplaysize}) | ||
| 57 | #end | ||
| 58 | |||
| 59 | #set ($title=$parampath.replace("//", "")) | ||
| 60 | #set ($title=$title.replace("%20", " ")) | ||
| 61 | #set ($title=$title.replace("/", " / ")) | ||
| 62 | |||
| 63 | <a href="/media/${parampath}/thumbs/${DisplaySizeDefault}pxHigh/${paramimage}" data-target="flare" data-flare-scale="fitmax" data-flare-gallery="${parampath}" data-flare-thumb="/media/${parampath}/thumbs/${ThumbSizeDefault}pxHigh/${paramimage}" tilte="${paramimage}" data-title="$title" data-description="<h3>$title / ${paramimage}</h3>"><img src=data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== class="b-lazy" data-src="/media/${parampath}/thumbs/${ThumbSizeDefault}pxHigh/${paramimage}" data-src-small="/media/${parampath}/thumbs/${ThumbSizeDefault}pxHigh/${paramimage}" /></a> | ||
| 64 | {{/code}} |