1

(11 replies, posted in Juicebox-Lite Support)

For anyone who's using ASP.NET MVC, I thought I'd share my code that I used to build the xml response.

I added this to my regular MVC controller and returned an ActionResult.  I would have used WebAPI, but my API controllers return only JSON by design.  JuiceBox requires xml.

I learned from Emi's post above, but I use LinqToXml's XElement and XDocument to build the xml which is generally safer as far as creating valid xml.

List<XElement> elements = new List<XElement>();
            foreach (var photo in listing.Photos)
            {
                XElement xElement = new XElement("image", 
                    new XAttribute("imageURL", photo.Url), 
                    new XAttribute("thumbURL", photo.ThumbnailUrl), 
                    new XAttribute("linkURL", photo.Url), 
                    new XAttribute("linkTarget", "_blank"));                
                
                if (!string.IsNullOrEmpty(photo.Caption))
                    xElement.Add(new XElement("caption", photo.Caption));
                
                elements.Add(xElement);
            }

            using (MemoryStream stream = new MemoryStream())
            {
                XDocument xDocument = new XDocument(
                        new XElement("juiceboxgallery", new XAttribute("galleryTitle", listing.Headline), elements));

                xDocument.Declaration = new XDeclaration("1.0", "utf-8", "true");
                xDocument.Save(stream);
                stream.Seek(0, SeekOrigin.Begin);
                var response = Encoding.UTF8.GetString(stream.ToArray());
                Response.ContentType = "application/xml";             
                return Content(response);
            } 

Thanks Steven, appreciate the help.  That got it working perfectly.

Hi,

I built a web service method that serves up the xml response, similar to the question thread that you pointed me to.

I configured the JavaScript configuration to call this url in a very simple configuration that looks like so:

    new juicebox({
        debugMode: true,
        containerid: 'juicebox-container',
        configUrl: '/listings/getimages/1'
        
    });

In the debugger, I can see that the web page calls into the xml response page, which returns xml as expected.  When I manually capture the xml info a config.xml file and place it on the server and remove the configUrl setting, then the web page displays images.  So, the format of the xml must be correct.  But something isn't working as expected, because the page isn't showing images when it tries to load them dynamically through the configUrl setting.

A demo of my main page is located at https://wineryandvineyard.com/listings/view/1.  You can verify the configuration in the page source.

The xml image service is located at https://wineryandvineyard.com/listings/getimages/1

If you hit the xml page you can see that it returns a correctly formatted response using the content-type application/xml.

Appreciate any ideas you have on how to solve this.

4

(495 replies, posted in Juicebox-Pro Support)

I'm using a web service to dynamically supply the file information to build a Juicebox display. 

Webservices today generally emit JSON, yet  Juicebox only consumes XML.  It would be ideal if Juicebox could support JSON, so that I didn't have to build a specific webservice to only feed Juicebox's XML needs.

Steven wrote:

If you know that all the images for a gallery are going to be in a certain folder, then you could use a server-side scripting language (such as PHP) to dynamically create the required XML file. An example of how this could be achieved can be found in this forum thread.

Thanks.  That link is gold.  It describes virtually identically what I need to do.  Although all of my images aren't in the same folder, I do have control over the web service so I can supply the information necessary to generate a list of full image URLs (not relative) in order to create the xml.

Now in the future if you could support reading JSON instead of or in addition to XML, then this would be terrific.

Hi, sorry for what may be a noob question.  I just bought Pro today because I liked the demo.  I didn't even try out Lite before I bought.

I was looking at the Embedding Guide pages and was confused by some of the terms such as JuiceBoxBuilder, etc.

I plan to use this for a real-estate web site, and I'll have no access to the image files that will be displayed.  Customers upload them, and then I'll get a list of files and captions to display through a JSON web service.  As you can imagine this is all dynamic pages, so I won't be using any pre-processing software like JuiceBoxBuilder etc.

Will JuiceBox work for me or is it aimed at a different use case?