Topic: Back Button images (continued from "Features Requests" thread)

Continued from this previous conversation, split off to avoid diluting the "Feature Requests" thread further (apologies for that).

@Steven

#1 is a compromise I'd be happy to accept in your case (23KB is not a huge overhead that I'd worry about).
#2 can easily be checked on a non-retina display to see if it looks OK. If it does not look OK, then my second suggestion above tackles this problem.

It looks fine to me, so hopefully no worries there - problem solved.
(Phew! I was concerned you'd be forced to explain, using rudimentary language, how to implement the embedding code you kindly created. I'm just about comfortable tinkering with the config.xml file, I'd hate to see the problems I could cause hacking away at the jbcore files!)

It looks like the alignment problem might happen only when you use a custom image for the Back Button.
Try adding a negative top margin of 5px to your Back Button image (via inline CSS). For example, try using something like the following for your backButtonText.

<img src="logo.jpg" width="100" height="75" style="margin-top: -5px;" />

That appears to work beautifully, thank you.
(My pseudo OCD is satisfied...we called it 'perfectionism' when I was younger!)

Does it matter that my backButtonText is becoming littered with "&quot" etc. in the config.xml file? I already run a couple of scripted alterations to the file before publishing and would be happy substituting a cleaner version of this...

backButtonText="&lt;img src=&quot;http://www.mydomain.com/resources/logo-backbutton-400x100.png&quot;width=&quot;200&quot;height=&quot;50&quot;style=&quot;margin-top:-5px;&quot;/>"

...if it doesn't matter than I'll happily leave it be.

Re: Back Button images (continued from "Features Requests" thread)

I'm glad you've been able to implement my suggestions and that they're working well for you.

The embedding code I provided as a solution for #2 (see this forum post) can actually just be copied and pasted directly into your gallery's HTML web page (replacing any existing embedding code). You'd just need to supply a second, higher-resolution image (and change the gallery dimensions and background color if necessary).

...if it doesn't matter than I'll happily leave it be.

Not only does it not matter, it actually needs to be like this.
All configuration option values are enclosed in double-quotes. If a value actually contains a double quote itself, then this double-quote needs to be escaped (as &quot;) so that it is not confused with the closing double-quote at the end of the value.
Likewise, any < characters within configuration option values need to be escaped as &lt; so that they are not seen as opening tags (which would break the XML syntax).
I hope that makes sense.

Escaping XML entities is mentioned in the following FAQ (with a link to an online XML escape tool if you every need to edit your XML file manually).
How do I add HTML formatting to the Gallery Title or Back Button?

Re: Back Button images (continued from "Features Requests" thread)

Steven wrote:

The embedding code I provided as a solution for #2 (see this forum post) can actually just be copied and pasted directly into your gallery's HTML web page (replacing any existing embedding code). You'd just need to supply a second, higher-resolution image (and change the gallery dimensions and background color if necessary).

Okay, you're absolutely correct; it is a very simple addition. (You can see the larger image load a fraction of a second after the original logo.)

So I've now added a scripted edit of JuiceboxBuilder's index.html file (these are stand-alone client galleries, not embedded into a page) into my client delivery workflow...not sure if the 5 extra seconds of my time is worth saving 11 KB of additional download which takes a fraction of a second, but I guess it's best practice <shrug>).

Regardless, this whole exercise has been educational (and reduced my reticence to edit these arcane files) - thank you, your help is much appreciated.

Re: Back Button images (continued from "Features Requests" thread)

My solution works OK but it is not as efficient as it could be.
As you've noticed, on a retina display, both images are loaded (and the the high resolution image can be seen to load after the low resolution image).

If would be more efficient to always load only one image (depending on the device pixel ratio) and from a visual standpoint, you would not see one image being loaded on top of another.
You could initially set backButtonText="" and use something like the following:

<!--START JUICEBOX EMBED-->
<script src="jbcore/juicebox.js"></script>
<script>
    var jb = new juicebox({
        containerId: 'juicebox-container',
        galleryWidth: '100%',
        galleryHeight: '100%',
        backgroundColor: '#222222',
        backButtonPosition: 'TOP',
        backButtonText: '',
        backButtonURL: 'http://www.example.com/index.html'
    });
    jb.onInitComplete = function() {
        var filename = (window.devicePixelRatio >= 2) ? 'large.jpg' : 'small.jpg';
        $('.jb-go-back-text').html('<img src="' + filename + '" width="100" height="75" />');
    };
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->

Just a small tweak to make things a little more streamlined.

5 (edited by TonyHall 2016-09-06 16:09:44)

Re: Back Button images (continued from "Features Requests" thread)

Okay, that works well (although I won't pretend that I understand it all!) - thank you.

However, the logo is now, very obviously, the last thing to load. The initial image cross fade transition completes (0.5 second) then the logo pops in. This is much more visually distracting than the logo subtly updating at the end (as with your previous solution).

So we've gone from saving non-retina viewers from downloading an unnecessary 11 KB, to making retina viewers download an additional 23 KB (using your previous solution which is visually smoother).

While I'm enjoying the tinkering, ultimately it's something my clients won't really notice and definitely won't care about! I feel guilty that you're spending this time and effort on something that is in reality a non-problem. (However, if you wish to continue refining things, I'll happily continue to try them out.)

You've fixed both of my back button logo issues (retina viewing and alignment) for which I'm extremely grateful.


Incidentally, I was just researching some old postings of mine (as the recent testing threw up a previously mentioned glitch with JuiceboxBuilder, which you answered - any progress?) and was slightly embarrassed to discover that I purchased Juicebox-Pro over 4 years ago and I'm only just implementing it thanks to the updates and steady improvements, hopefully Juicebox will continue to evolve.

Re: Back Button images (continued from "Features Requests" thread)

The code above just took a minute to come up with as an alternative to my previous suggestion.
As long as you've been able to resolve your problem with a solution that you're happy with, that's great.

Unfortunately, the glitch with JuiceboxBuilder (whereby an error can be generated if the resize image dimensions are too large) has not yet been fixed but it has been logged as a bug and should be addressed by the developers in due course.
In the meantime, if you need to have large images in your gallery and find that JuiceboxBuilder is unable to resize them as required, then you could perhaps manually resize your images in an imaging program such as Adobe Photoshop before feeding them to JuiceboxBuilder and deselect the 'Resize Images' checkbox on the 'Images' tab (so that JuiceboxBuilder simply copies the images across to the output gallery folder).

Re: Back Button images (continued from "Features Requests" thread)

Hi Steven,

I've been very happy with your solution (replacing the standard logo with a hi-res version after page load for retina screens) but have noticed a slight anomaly.

When viewing the gallery full screen via the Expand Gallery button the hi-res logo doesn't load in the expanded mode. Is there any additional code you can devise to provide this?

Another alternative that comes to my tiny mind (feel free to chuckle at my ignorance!), is to return to the slightly less efficient method of loading a hi-res logo regardless. I assume this will work for both viewing the expanded full screen mode as well as providing a hi-res logo for those viewing with hi-dpi screens (not sure of the official terminology) on non-Mac devices, which I believe isn't currently supported in Juicebox-Pro v1.5.

Should you need it, here's a test gallery.

Many thanks in advance.

Re: Back Button images (continued from "Features Requests" thread)

You could try something like the following:

<!--START JUICEBOX EMBED-->
<script src="jbcore/juicebox.js"></script>
<script>
    var jb = new juicebox({
        containerId: 'juicebox-container',
        galleryWidth: '100%',
        galleryHeight: '100%',
        backgroundColor: '#222222',
        backButtonPosition: 'TOP',
        backButtonText: '',
        backButtonURL: 'http://www.example.com/index.html',
        useFullscreenExpand: 'TRUE'
    });
    jb.onInitComplete = function() {
        var filename = (window.devicePixelRatio >= 2) ? 'large.jpg' : 'small.jpg';
        $('.jb-go-back-text').html('<img src="' + filename + '" width="100" height="75" />');
    };
    jb.onExpand = function(expanded) {
        if (expanded) {
            window.setTimeout(function() {
                var filename = (window.devicePixelRatio >= 2) ? 'large.jpg' : 'small.jpg';
                $('.jb-go-back-text').html('<img src="' + filename + '" width="100" height="75" />');
            }, 500);
        }
    };
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->

The new part is the jb.onExpand code. You could restructure the code to make it more efficient and avoid duplication but I've just left it as it is (with the new code being just a separate addition to the code from my post above) so that's it's easy to follow.
Unfortunately, a short delay is required to ensure that the Back Button is present in the DOM (Document Object Model) before actions are performed on the CSS class after the gallery has been expanded.
The code is starting to get a little messy. This is one of the drawbacks of trying to do something with Juicebox that it was not designed to do. You tend to run into unforeseen problems and have to deal with them as your encounter them.

... is to return to the slightly less efficient method of loading a hi-res logo regardless.

I would probably be inclined to do this myself. For the sake of a handful of kilobytes, the code would be cleaner and it should work in all scenarios without any further tweaking.
Just use a backButtonText entry such as the following (making sure that the display width and height are both half the actual dimensions of the image).

backButtonText="&lt;img src=&quot;http://www.tonyhallphoto.com/jbresources/logo-backbutton-200x50.png&quot; style=&quot;width: 100px; height: 25px; margin-top:-5px;&quot; /&gt;"

... on non-Mac devices, which I believe isn't currently supported in Juicebox-Pro v1.5.

In a Multi-Size Image gallery, 'Large' images are not currently displayed in high pixel density Windows desktop monitors but this has been logged as a bug and should hopefully be fixed in the next version of Juicebox.

Re: Back Button images (continued from "Features Requests" thread)

Once again, many thanks Steven for your exemplary support, it's much appreciated.

Steven wrote:

The code is starting to get a little messy. This is one of the drawbacks of trying to do something with Juicebox that it was not designed to do. You tend to run into unforeseen problems and have to deal with them as your encounter them.

... is to return to the slightly less efficient method of loading a hi-res logo regardless.

I would probably be inclined to do this myself. For the sake of a handful of kilobytes, the code would be cleaner and it should work in all scenarios without any further tweaking.

I absolutely agree, I'll revert to the original simple solution as I fear (maybe incorrectly) that the more I customise the workings of Juicebox-Pro the greater the chance something may break with future updates.

Although we've come full-circle with this trivial tweak, it's been an interesting exercise for me and I've learnt some things along the way - excellent!

Cheers!

Re: Back Button images (continued from "Features Requests" thread)

... (maybe incorrectly)...

No. You're absolutely right. You're likely to have far less problems upgrading if you stick to the available configuration options and supported features.
Tweaking functionality via internal CSS classes (ie. unsupported modifications) is all well and good if you just have a single stand-alone gallery which you don't plan to upgrade frequently (or at all) but if you have multiple galleries throughout your site and CSS class names change between Juicebox versions (which is unlikely but could happen), then you might find you have quite a task on your hands getting everything back up and running again.
It's usually wise to stick to the safest (and often easiest) solutions, even if it means compromising a little.