1

Topic: Embedding a responsive gallery into a Shopify web page [SOLVED]

Hi,

I've just bought Juicebox Pro and am trying to embed a gallery into Shopfiy. I've done this on a test page here: https://www.charleychau.com/pages/test-gallery but because the iframe width has to be set, it looks dreadful on mobile - see screenshot attached.

Is there any way of embedding a Juicebox gallery into a Shopify web page so that it is responsive?

Any help on this much appreciated.

Thanks,
Christine

Post's attachments

IMG_7811.PNG 123.59 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

If the width of your iframe is of concern, then you could try giving your iframe a width of 100% (either via the 'width' attribute or inline CSS):

<iframe src="https://www.gallery.charleychau.com/test-gallery/index.html" width="100%" height="600" frameborder="0" scrolling="no"></iframe>
<iframe src="https://www.gallery.charleychau.com/test-gallery/index.html" height="600" frameborder="0" scrolling="no" style="width: 100%;"></iframe>

It the layout of your gallery page is the problem, then you're seeing the thumbnail page of Small Screen Mode for the following reasons:
(1) Small Screen Mode is used by default on mobile devices.
(2) When a gallery is embedded with dimensions of 100% x 100% on a page of its own (with no other content), then the Splash Page is not used (and the thumbnail page is the first thing you'll see in Small Screen Mode). Your gallery fits this description as it is embedded full-page in 'index.html' on your 'charleychau.com' domain.

As you have uploaded your gallery to a regular web server which you seem to have control over, perhaps the best option would be to embed your gallery using the baseUrl method (using absolute paths) and ensure that you set up a CORS (cross-origin resource sharing) solution. More information about CORS can be found here.
Normally, trying to embed a Juicebox gallery hosted on one domain and whose embedding code is on another will not work due to the Same-Origin Policy.
However, if you add the following code to an '.htaccess' file in the root directory of your 'charleychau.com' domain (where your gallery is hosted):

Header add Access-Control-Allow-Origin "*"

... then you should be able to replace the iframe in your Shopify page with the following code to embed your Juicebox gallery directly into your Shopify page:

<!--START JUICEBOX EMBED-->
<script src="https://www.gallery.charleychau.com/test-gallery/jbcore/juicebox.js"></script>
<script>
  new juicebox({
    baseUrl: "https://www.gallery.charleychau.com/test-gallery/",
    containerId: "juicebox-container",
    galleryWidth: "100%",
    galleryHeight: "600",
    backgroundColor: "#222222"
  });
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->

I hope this works for you.

3

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

Hi,

Thanks for the quick response.  It's not purely an issue on width, I need a fully responsive gallery to embed on our site that is hosted by Shopify.

Unfortunately I am not technically capable in any way shape or form and yesterday had a real struggle even getting to the point where I set up a subdomain with web space to host the gallery, and then work out the FTP situation so just getting to a point where I had a vaguely working gallery was a miracle frankly.

Back to what you suggested ...

Setting the width at 100% using inline CSS

I have set the width to 100% as you suggested and it looks fine on load when viewed on mobile portrait as shown here: http://gallery.charleychau.com/screensh … n-load.png

If the user then flips the mobile device to a landscape view the gallery is displayed at 100% width as you would expect as shown here: http://gallery.charleychau.com/screensh … dscape.png

BUT if the user then rotates their screen back to portrait view on mobile, the screen is not re-sizing properly, as shown here: http://gallery.charleychau.com/screensh … tating.png and you can see the header of the website has been distorted.

Is there something I can do to resolve this problem?

Using baseURL option

I am not technical in the slightest but I found the .htaccess file. The existing code in the .htaccess file was:

CheckSpelling Off
AddType x-httpd-php56 .php

So I simply added the line of code that you suggested so that the code in the file is now:

CheckSpelling Off
AddType x-httpd-php56 .php
Header add Access-Control-Allow-Origin "*"

And I uploaded it via FTP to the server where the gallery is hosted which is a subdomain of charleychau.com: gallery.charleychau.com and hosted on a standalone webserver that I set up yesterday specifically because of trying to use Juicebox.

I then embedded the code that you suggested in a web page on our main website at charleychau.com which is hosted by Shopify on different servers and I do not have full control of the Shopify servers.

But the gallery does not display: https://www.charleychau.com/pages/test-gallery-2

And has an error message “Juicebox Error: Config file not found”.

What has gone wrong?

Sorry if I am asking silly questions but I’m not technical and I bought Juicebox Pro because it says on the home page of your site: “Use Juicebox to create spectacular HTML5 image galleries for your web site with no coding required. Juicebox is simple to set up and use, and includes complete browser and mobile device support.”

It would be great if I can get something working correctly here otherwise I think we’re going to have to give up with Juicebox.

Thanks!

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

First of all, I would try to embed the gallery directly into the web page that you want the gallery to appear in.
This should prevent you from having to deal with iframe problems on mobile devices.

Next, if your Shopify page is actually on your own domain (the same domain where your gallery folder has been uploaded to), then there should be no need to use a CORS solution. You should be able to just use the regular embedding code (or the baseUrl embedding code if you have uploaded the entire gallery folder rather than just its contents).

But the gallery does not display: https://www.charleychau.com/pages/test-gallery-2

This is because you've uploaded the .htaccess file to gallery.charleychau.com but the paths in the embedding code point towards www.gallery.charleychau.com (note the different 'www' subdomain). (When I posted the code above, I just copied the path from the 'src' attribute of your iframe.)

Try changing the two paths in your embedding code from www.gallery.charleychau.com to just gallery.charleychau.com.

Alternatively, if you have direct access to the charleychau.com web space, then there is no need to have created a 'gallery' subdirectory (and it is probably just complicating matters).

If you can, upload your complete 'test-gallery' folder to the root directory of your charleychau.com domain and use the following embedding code in your 'test-gallery-2' page.

<!--START JUICEBOX EMBED-->
<script src="/test-gallery/jbcore/juicebox.js"></script>
<script>
  new juicebox({
    baseUrl: "/test-gallery/",
    containerId: "juicebox-container",
    galleryWidth: "100%",
    galleryHeight: "600",
    backgroundColor: "#222222"
  });
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->

This should hopefully be all that is required to allow the gallery to work when users visit either charleychau.com or www.charleychau.com.

5 (edited by CC 2017-06-07 16:16:06)

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

Hi Steven,

Thanks again for the quick response. Just to clarify, our Shopify store (domain is www.charleychau.com) is on servers that we have no control over and cannot upload gallery files to. So I set up a subdomain (http://gallery.charleychau.com) on  separate standalone server so that I could upload gallery files to use Juicebox.

It means I think that the embed code option just won;t work for us.

This is because you've uploaded the .htaccess file to gallery.charleychau.com but the paths in the embedding code point towards www.gallery.charleychau.com (note the different 'www' subdomain). (When I posted the code above, I just copied the path from the 'src' attribute of your iframe.)
Try changing the two paths in your embedding code from www.gallery.charleychau.com to just gallery.charleychau.com.

I've done this and the test gallery now displays and works perfectly on desktop and iPad: https://www.charleychau.com/pages/test-gallery-2

However there is a problem when viewing on mobile. The gallery displays on load as shown here: http://gallery.charleychau.com/test-gallery/images/juicebox-gallery-test-2-on-mobile.PNG

When I click "View Gallery", it tries to load a new page with the URL https://gallery.charleychau.com/test-ga … /full.html but I get an error message "Juicebox Error: Config file not found." as you can see here: http://gallery.charleychau.com/test-gallery/images/juicebox-gallery-test-2--on-mobile-error.PNG

As you can see here https://gallery.charleychau.com/test-gallery/jbcore/ the full.html file is on the server. But when I click on it on the file to open it I get the same error message .

Please could you let me know what to do to fix this. I feel like we're so nearly there!

Thanks,
Christine

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

I'm pretty sure this is a Cross-Origin issue. I've been able to replicate the problem myself in a test scenario but, unfortunately, I've been unable to find a good solution.

Normally, your gallery is hosted on gallery.charleychau.com but is displayed on charleychau.com.
However, when the gallery is expanded from the Splash Page, it is displayed via the 'full.html' page within the 'jbcore' folder on gallery.charleychau.com (swapping the domain on which the gallery is being displayed). To complicate matters, Juicebox passes configuration options to the 'full.html' page via a session cookie.

I've tried adding the following line to the .htaccess in my test scenario file to add cookie support to the CORS solution.

Header set Access-Control-Allow-Credentials true

... and I've tried adding the full .htaccess file:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Credentials true

... to both domains (in theory to allow access in both directions) but it does not work.

The only thing I've been able to think of would be to set expandInNewPage="FALSE" to prevent the gallery from being displayed via the 'full.html' page when it is expanded from the Splash Page. The gallery will then be expanded on top of the embedding page (still on the charleychau.com domain) which may cause a scaling problem on iOS devices. (Expanding the gallery on a page of its own is designed to avoid this potential scaling issue.) It's certainly worth a try, though.
Alternatively, you could keep expandInNewPage="AUTO" and lock the viewport of your gallery's web page.
Please see the Expand Gallery Behavior support section for details.

I hope this is a suitable workaround for your problem (as it seems to work well in my test scenario).

7

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

Hi Steven,

Thanks for looking into this. I think I've found a workable solution and I've now implemented it with a gallery embedded onto our blog: https://www.charleychau.com/blogs/blog- … le-of-bute

I changed the settings for:

  • Expand in New Page to FALSE as you suggested

  • Show Splash Page to NEVER

It means that the gallery loads on mobile like this: https://gallery.charleychau.com/screenshots/mobile-portrait-thumbnails.PNG

And when a user clicks a thumbnail the image is displayed like this: https://gallery.charleychau.com/screenshots/mobile-portrait-image-open.PNG

I've checked this over on mobile, iPad and desktop and it all looks like it works fine with one tiny exception - highlighted in the red box on the image below:
https://gallery.charleychau.com/screenshots/mobile-portrait-image-open-highlighted.png

The thumbnail view icon is partially obscured when viewing an image on mobile in portrait orientation. It's not a massive problem but if you know of a way to re-align it then I would be grateful.

Thanks,
Christine

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

I'm glad you've been able to find a suitable workaround. Thank you for letting me know.
With regard to you Button Bar issue, this looks like it might be caused by a known bug where the Button Bar does not always wrap correctly when there is insufficient space for all the buttons. The developers are aware of this issue and it should hopefully be fixed in the next version. In the meantime, it might help to change the size of the Button Bar icons via buttonBarIconSize (in JuiceboxBuilder-Pro's 'Customize -> Button Bar' section). The default value is 20 so you could try using a slightly smaller or larger value. Hopefully this will help.

9

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

Had a think about this and it seems that the thumbnail icon not displaying is simply down to too many buttons on the control bar. I set re-set my sharing buttons so that only FB and Twitter are enabled, thus removeing G+. REmoving one icon from the control bar means that he thumbnail view is now showing in full as shown here:

http://gallery.charleychau.com/screenshots/mobile-portrait-image-open-edited.png

So all in all, looks like I have got this working now but with some compromises on functionality.

Cheers!

10

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

Sorry, our posts crossed and I saw your last response after I had posted my last one. I've re-sized the buttons and that has worked. Perfect.

Thanks again.

Christine

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

No problem! I'm glad my suggestion worked. Thanks for letting me know.

Re: Embedding a responsive gallery into a Shopify web page [SOLVED]

The issue raised in this thread (regarding the Button Bar not wrapping when it should) has now been fixed in v1.5.1 which has just been released (25 August 2017).
Please see the Version History for a full list of changes.
Full instructions for upgrading can be found on the Upgrading Juicebox support page.