banner
Advertising


Lightroom-News.com
LRN Contents
Calendar
LRN Archives
Meta
RSS Feeds


Lightroom-News.com

The lastest news and info about Adobe Photoshop Lightroom


October 19, 2008

HTML Gallery: Live Update.

In our previous installment we discussed adding Styles to our gallery, but discovered that we needed to restart Lightroom to see the changes. Now we look at automatic refreshing in Lightroom.

In order to have our gallery refresh on the fly without having to constantly restart, Lightroom uses a Javascript file called live_update.js. This file detects when changes are being made in the panel and refreshes the page to suit. Some changes will force a full refresh, other will refresh the HTML/CSS only. Why is a such a file necessary? Well, when you look at a gallery in Lightroom, you’re actually looking at a web browser running independently of the main program. On PC it’s IE based, while on Mac, it’s Safari. Because a browser doesn’t inherently know that changes have been made, we need to let it know they have, hence live update.

To add live update to our gallery we need to get the file first. You can get this file from the Lightroom SDK, the default html gallery, or even from 3rd party galleries like my own or from The Turning Gate.

In the resources folder we created already, add a folder called ‘js’, then add the file live_update.js to it.

Open the HTML and under the css link, add the following following:

<script type="text/javascript">
window.AgMode = "$mode";
</script>
<script type="text/javascript" src="resources/js/live_update.js">
</script>

The window.AgMode lets Lightroom know when it needs to use Live Update.

Save the HTML file and restart Lightroom. Click on the colour chip to active the color picker. The background colour should now change as you move around the colour picker.

In the background Live Update reads the information you are changing and decides what kind of refresh is needed. If the settings affect the current page, it will be refreshed. If they affect the CSS file, then everything except the generated Jpeg files are refreshed. Changing an image size will refresh the images, as will watermarking, sharpening and quality changes. There’s also a case for an exception forcing the gallery to reload.

You can add cases to the live_update file for specific settings if you want. It’s beyond the scope of this series, but well covered in the SDK.

Previous Posts:
1. Anatomy of a HTML Gallery
2. The galleryInfo.lrweb file
3. The manifest.lrweb and html files
4. Adding styles
5. Live Update

Leave a Reply

You must be logged in to post a comment.