This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 16 - Pages: 2 [ 1 2 | Next ] - Last Post: 26 Aug 25, 18:25 Last Post By: RobM Threads: [ Previous | Next ]
RobM

Posts: 3,991
Registered: 4-Aug-2006
renderer.buildSrcset broken passing 'path'
Posted: 11 Aug 25, 20:50
 
  Click to reply to this thread Reply
The renderer.buildSrcset call no longer returns the path attribute.

API code
public static String buildSrcset(List<Rendition> renditions,
String typicalPath)
Generate a srcset attribute value for given list of renditions


Usage, in Journal skin, where 'path' is 'slides/'
def getImageSet(AlbumObject ao, OutputFormat outf, path)  {
 //to hold the comma separated list of images
 imageSet = "";
 //Check for the existence of an srcset
  if (ao.getVars().get("imageRenditions") != null) {
  //One exists, so get the renderer
  ImageRenderer renderer = ao.getRenderer();
  //Build an srcset of output format either WEBP or JPEG (or png, gif etc.)
  //Note the need for the ’slides/‘ path to get to the slides images
  imageSet = renderer.buildSrcset(renderer.getCloseupRenditions(outf), path);
  }
 //Return the images of the required output format
 return imageSet;
}

The result, (for jpg set, I'm using two sets, jpg and webP) in jAlbum prior to 35 is, for example
srcset="slides/Owl.jpg 800w,slides/Owl.jpg 800w"

The result in jAlbum 35 onwards is, for example
srcset="Owl-1000w.jpg 1000w,Owl.jpg 800w"

This results in a missing image if srcset is used.

Edited by: RobM on 12 Aug 2025, 12:22
Since version 35 came out two years ago it is probably safe to say no other skin developer uses the API call and no, if any, users of Journal skin uses variants. I
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 20 Aug 25, 20:07   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Edited by: RobM on 22 Aug 2025, 16:55
Removed out of date content.
JeffTucker

Posts: 8,360
Registered: 31-Jan-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 21 Aug 25, 15:36   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I know this isn't actually a fix for the bug, but could the skin take the returned String, do a split() on it, prepend the needed path to each token, then concatenate them again?

ETA: A quick cobble:
String apiresult = "thing1,thing2,thing3";
String[] newarray = apiresult.split(",");
String result="slides/" + String.join(",slides/", newarray);
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 21 Aug 25, 17:54   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
I know this isn't actually a fix for the bug, but could the skin take the returned String, do a split() on it, prepend the needed path to each token, then concatenate them again?

ETA: A quick cobble:

String apiresult = "thing1,thing2,thing3";
String[] newarray = apiresult.split(",");
String result="slides/" + String.join(",slides/", newarray);
Thanks for the code. I believe that would work, except I think it is String.Join

I split the variants into two groups, webp and jpeg, so I would have to do it twice for each slide image. I’ve already posted a fixed skin version by disabling the variants and no one has asked for it to be enabled or when it could be enabled. The code has been left in but I’m minded to just leave it as it is.

It’s only a problem if a skin places the slide images on the index page and uses variants (also complicated a bit by supporting faces/regions).
JeffTucker

Posts: 8,360
Registered: 31-Jan-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 21 Aug 25, 18:01   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
I believe that would work, except I think it is String.Join

Nope. Lowercase. Code copied from a live console test. ;)
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 21 Aug 25, 18:14   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
RobM wrote:
I believe that would work, except I think it is String.Join

Nope. Lowercase. Code copied from a live console test. ;)

Stackoverflow let me down this time.
JeffTucker

Posts: 8,360
Registered: 31-Jan-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 21 Aug 25, 18:33   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Of course, if you want to get really rigorous about it, engine.getSlideDirectory() would need to be called. But that's not settable in the UI, unlike index and .html, so finding anything else would be long odds.
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 21 Aug 25, 20:52   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
OK. I've changed the code from lax to rigorous - only eight places - in the event I decide to update the skin again.
davidekholm

Posts: 3,975
Registered: 18-Oct-2002
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 13:52   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
The "path" argument needs to be the full relative path to the typical image, i,e. the image that isn't a Variant, so just pass "imagePath" or "thumbPath" as argument to buildSrcSet and it will work on all jAlbum versions.

I acknowledge that the docs could be better, but you get a hint here :
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 15:31   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
The "path" argument needs to be the full relative path to the typical image, i,e. the image that isn't a Variant, so just pass "imagePath" or "thumbPath" as argument to buildSrcSet and it will work on all jAlbum versions.

I acknowledge that the docs could be better, but you get a hint here :

My slide images appear on the index page, not on slide pages and not in a lightbox. imagePath would give the wrong path. I use
 imageSet = renderer.buildSrcset(renderer.getCloseupRenditions(outf), path);
where path is ‘slides/‘.

That worked until jAlbum 35 came out. If you want to try it install Journal skin and change the properties file so variants are supported. When you build an album the images are missing. Reverting to jAlbum 34 works.
davidekholm

Posts: 3,975
Registered: 18-Oct-2002
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 16:00   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
If you add imagePath, that will prepend "slides/" to each image reference and it will work with older jAlbum versions as well. Isn't that what you're after?

I checked the code and can confirm the change in behaviour when only passing "slides/" as path argument, but it's honestly a mystery to why that that has changed. You could even pass "slides/foo.jpg" as path argument. The method simply gets the parent path, which is "slides/"
JeffTucker

Posts: 8,360
Registered: 31-Jan-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 16:11   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
... it's honestly a mystery to why that that has changed.

Another stealthy attack by the Code Gnomes™.

noun: Malignant creatures who invade a developer's computer and damage his finely crafted code. Jaded skeptics maintain that these miscreants are purely the invention of developers, designed to serve as fall guys who take the blame for coding that results in weird and/or hard to track down errors. This reveals how little they know.
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 16:44   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
If you add imagePath, that will prepend "slides/" to each image reference and it will work with older jAlbum versions as well. Isn't that what you're after?
Yes, that’s what I want, so I’ll change the code from a string to the variable.
I checked the code and can confirm the change in behaviour when only passing "slides/" as path argument, but it's honestly a mystery to why that that has changed. You could even pass "slides/foo.jpg" as path argument. The method simply gets the parent path, which is "slides/"
Normally I like a good mystery ;)
davidekholm

Posts: 3,975
Registered: 18-Oct-2002
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 17:24   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
Normally I like a good mystery ;)

Yes, this change bugs me. There doesn't seem to be any change to that method, or to the underlying IO.parentPath() call since v34.3, still v34.3 works when passing "slides/", but not the current version. Just pass the slidePath variable instead.
RobM

Posts: 3,991
Registered: 4-Aug-2006
Re: renderer.buildSrcset broken passing 'path'
Posted: 22 Aug 25, 20:30   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
If you add imagePath, that will prepend "slides/" to each image reference and it will work with older jAlbum versions as well. Isn't that what you're after?

I checked the code and can confirm the change in behaviour when only passing "slides/" as path argument, but it's honestly a mystery to why that that has changed. You could even pass "slides/foo.jpg" as path argument. The method simply gets the parent path, which is "slides/"

If this gives you any insight into the mystery:
API IO.parentPath (stripping stuff after last /)

Case 1, with actual image name
IO.parentPath("Animals/slides/owl.jpg") = Animals/slides/

Case 2, without image name, that's not after the last '/'
IO.parentPath("Animals/slides/") = Animals/
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums