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


Permlink Replies: 38 - Pages: 3 [ 1 2 3 | Next ] - Last Post: 28-Mar-2018 10:46 Last Post By: davidekholm Threads: [ Previous | Next ]
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Getting the slide image for a folder
Posted: 21-Mar-2018 22:21
 
  Click to reply to this thread Reply
Tough to explain, but this is one of those things that always stumps me.

Imagine a project that has a folder structure, with images only at the lowest level. The project is called TEST. It has a folder called F1. F1 has a subfolder called SUB1. SUB1 has three images in it.

Now, I select mydog.jpg from SUB1 to be the folder thumbnail. I choose SUB1 to be the folder thumbnail for F1. I choose F1 to be the folder thumbnail for TEST. So, TEST/F1/SUB1/thumbs/mydog.jpg is the presenting thumbnail for the project.

Now I want to use TEST/F1/SUB1/slides/mydog.jpg as a background image at the top level of the album. I'm processing the root. I'm in index.htt, but not in an iterator loop yet. How do I get the path to TEST/F1/SUB1/slides/mydog.jpg (or even to the thumbnail, for that matter)?
RobM

Posts: 3,049
Registered: 4-Aug-2006
Re: Getting the slide image for a folder
Posted: 21-Mar-2018 23:02   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Maybe something based on one of these
<%=rootFolder.getVars().get("thumbPath") %>
<%=rootFolder.getVars().get("imagePath") %>
Though you still need to jiggle the result a bit to get the the path just right - remove the root folder element from the path.
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 21-Mar-2018 23:26   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Thanks, that gets me fairly close. For a more generalized solution, I can use currentFolder, so I can pull the same trick at the folder level.

Need to strip off the leading directory - there must be a handy method for that somewhere. I hate reinventing the wheel.

Also need to check to make sure I don't grab folder.png, if the user isn't using folder thumbnails! A null check on iconPath will take care of that part nicely.
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 00:12   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
One weird little problem. If I choose Link to originals, the imagePath variable still returns the path to the slides image, which doesn't even exist. I'm not even sure what I can check to avoid that error.
RobM

Posts: 3,049
Registered: 4-Aug-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 00:16   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
The complication comes with checking if 'URL encode links' has been set or 'Generate web safe names', as the length of the root name can change if there are spaces in it.
Example, with URL encode you get 'MY%20Sample%20Portfolio/' but with web safe names 'MY Sample Portfolio'.

Maybe there is an API call that will be easier?
RobM

Posts: 3,049
Registered: 4-Aug-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 00:38   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Not sure, it is late and I'm off to bed but you could try rootFolder.getVars().get("lastFolderImagePath")
That give the path from the root folder to the original image used as the thumbnail, which might be easier to modify to add thumbs/slides as required.

Interestingly I can't find any documentation on lastfolderImagePath.
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 00:41   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
The complication comes with checking if 'URL encode links' has been set or 'Generate web safe names', as the length of the root name can change if there are spaces in it.
Example, with URL encode you get 'MY%20Sample%20Portfolio/' but with web safe names 'MY Sample Portfolio'.

That's not a problem - you just split() the path on "/", and drop the first chunk.

The imagePath problem when linking to originals is the showstopper. Need David's help on this one.
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 02:21   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Just a random thought, but the skin I'm working on doesn't actually use theme images. So, I could probably hijack themePath, which coughs up exactly what I need in every case, as long as the theme image dimensions are set equal to the image bounds.
RobM

Posts: 3,049
Registered: 4-Aug-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 09:09   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
Just a random thought, but the skin I'm working on doesn't actually use theme images. So, I could probably hijack themePath, which coughs up exactly what I need in every case, as long as the theme image dimensions are set equal to the image bounds.
As long as the user does not decide to ‘remove’ the theme image, though I can’t recall if one can remove the theme image when separate thumbnail and theme image is not allowed.
davidekholm

Posts: 3,548
Registered: 18-Oct-2002
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 11:04   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I'm sorry this has become an area of confusion. You can grab the "imagePath" variable from the current folder and strip the 1:st part which is the folder's name itself. Here's a way (index.htt, outside any iterators):
<ja:enter>
real image path: <%= imagePath.substring(imagePath.indexOf('/') + 1) %> <br>
</ja:enter>
(The ja:enter tag gives access to the current folder's variables when being outside of an iterator. Without it, you only get access to variables that are specific to folders only, like level). If you don't want to use the ja:enter element, then you can use the AlbumObject API:
imagePath: <%= String ip = currentFolder.getVars().get("imagePath"); ip.substring(ip.indexOf('/')+1) %> <br>


The reason why the folder's own name is prepended to the path is that this variable is intended to be referred to from the parent folder (in an iterator presumably)
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 11:26   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
jGromit wrote:
Just a random thought, but the skin I'm working on doesn't actually use theme images. So, I could probably hijack themePath, which coughs up exactly what I need in every case, as long as the theme image dimensions are set equal to the image bounds.
As long as the user does not decide to ‘remove’ the theme image, though I can’t recall if one can remove the theme image when separate thumbnail and theme image is not allowed.

Yes, the user can remove it, but in this situation, that's not really a problem. It's the same as having an empty folder - there's no theme image, so the skin has to take that into account, and not try to use it.
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 11:37   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
I'm sorry this has become an area of confusion. You can grab the "imagePath" variable from the current folder and strip the 1:st part which is the folder's name itself.

I must be getting better at this stuff - with Rob's help, that's exactly the solution I had gotten to, almost character-for-character.

But there's a bug. The imagePath returns the path to the slide image, even when LInk to originals has been selected, and there is no slide image. That probably needs to get fixed some day - I don't imagine that any skin would actually be using the variable this way, or the bug would have shown up before now.

But no reason to rush into a fix. The way I'm using this image, grabbing themePath is the way to go. I see that Zigzag is doing that, as well. The only twist is that I'll want to change the crop mask aspect ratio to match the image bounds. That should be reasonably easy.
davidekholm

Posts: 3,548
Registered: 18-Oct-2002
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 12:06   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
RobM wrote:
The complication comes with checking if 'URL encode links' has been set or 'Generate web safe names', as the length of the root name can change if there are spaces in it.
Example, with URL encode you get 'MY%20Sample%20Portfolio/' but with web safe names 'MY Sample Portfolio'.

That's not a problem - you just split() the path on "/", and drop the first chunk.

The imagePath problem when linking to originals is the showstopper. Need David's help on this one.


Oh, I notice that "imagePath" for folders is declared even when it points to a non-existing image, as is the case when linking to originals only. Man, the whole code that generates these *Path variables is a mess :-(. If you can get along with themePath instead, that would be great.

What's really needed here, and has been needed for years, is to rewrite the code that generates the *Path variables. What makes the code complex is that we handle several types of objects (images and non images) and different image linking modes. The path variables also adjust to whether they are referred to from an index page or a slide page. The number of permutations here is huge.
jGromit

Posts: 7,277
Registered: 31-Jan-2006
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 12:20   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
What makes the code complex is that we handle several types of objects (images and non images) and different image linking modes.

You mean like referring to processed, non-original videos with originalPath? Too bad no one ever warned you about doing that.
davidekholm

Posts: 3,548
Registered: 18-Oct-2002
Re: Getting the slide image for a folder
Posted: 22-Mar-2018 12:23   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
davidekholm wrote:
What makes the code complex is that we handle several types of objects (images and non images) and different image linking modes.

You mean like referring to processed, non-original videos with originalPath? Too bad no one ever warned you about doing that.


That's just one of several cases I guess. The code would need a tasteful rewrite that makes some path choices more logical without breaking skins too much.
Legend
Forum admins
Helpful Answer
Correct Answer

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