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


Permlink Replies: 10 - Pages: 1 - Last Post: 3 Dec 23, 16:57 Last Post By: JeffTucker Threads: [ Previous | Next ]
wiener30

Posts: 22
Registered: 8-Sep-2009
How to get path to folder thumbnail in index.hht?
Posted: 2 Dec 23, 15:53
 
  Click to reply to this thread Reply
Iterating in index.htt over folders, how to a get path to a thumbnail of the current folder.

I have tried
 ${thumbPath} 

but it returns strangely a folder name with the extension jpeg

I have tried
 IO.urlEncode(rootFolder.getThumbnailPath()) 

It returns correctly thumbnail to the album folder.

How to get a thumbnail of the current folder?
davidekholm

Posts: 3,975
Registered: 18-Oct-2002
Re: How to get path to folder thumbnail in index.hht?
Posted: 2 Dec 23, 16:06   in response to: wiener30 in response to: wiener30
 
  Click to reply to this thread Reply
Have you tried currentFolder.getThumbnailPath()
wiener30

Posts: 22
Registered: 8-Sep-2009
Re: How to get path to folder thumbnail in index.hht?
Posted: 2 Dec 23, 21:39   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
currentFolder works, but it is a folder over whose sub-folders I am iterating.
And I need folder thumbs of sub-folders of a currentFolder.

I have found some solution. There is a method returning children of a currentFolder. i.e., sub-folders. In this case it is necessary to pick the correct child and for this child with a method
 child.getThumbnailPath() 

the folder thumbnail could be retrieved.

But it is quite complicated and time-consuming.

Maybe there is a more simple method to do the same?
JeffTucker

Posts: 8,359
Registered: 31-Jan-2006
Re: How to get path to folder thumbnail in index.hht?
Posted: 2 Dec 23, 21:54   in response to: wiener30 in response to: wiener30
 
  Click to reply to this thread Reply
If you're within a file iterator loop, ${thumbPath} always returns the thumbnail that represents the folder. Stripped down:
<ja:fileiterator dirs>
<div><a href=${closeupPath}>
<img src=${thumbPath} width=${thumbWidth} height=${thumbHeight} alt="">
</a></div>
</ja:fileiterator>
JeffTucker

Posts: 8,359
Registered: 31-Jan-2006
Re: How to get path to folder thumbnail in index.hht?
Posted: 2 Dec 23, 22:12   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
And if you're doing your own iteration over the album objects, rather than using a jAlbum tag, you need something like this:
<%
for(AlbumObject aof : currentFolder.getChildren(Category.folder)) {
	if(aof.isIncluded() && !aof.isHidden()) {
		Map fvars = aof.getVars();
		fpath = fvars.get("closeupPath");
		fthumb = fvars.get("thumbPath");
		(do whatever it is you're going to do with them)
	}
}
%>
And remember, if your skin is creating separate folder thumbnails, the path to the thumbnail really will be something like thumbs/Foldername.jpg. That's where the core stashes those "special" folder thumbnails. If the skin is not using folder thumbnails, the path to the folder thumbnail will be something like Foldername/thumbs/mydog.jpg.

Edited by: JeffTucker on 2 Dec 2023, 16:18 - code tweak
wiener30

Posts: 22
Registered: 8-Sep-2009
Re: How to get path to folder thumbnail in index.hht?
Posted: 2 Dec 23, 22:31   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Thank you.
davidekholm

Posts: 3,975
Registered: 18-Oct-2002
Re: How to get path to folder thumbnail in index.hht?
Posted: 3 Dec 23, 10:26   in response to: wiener30 in response to: wiener30
 
  Click to reply to this thread Reply
Thanks for helping out Jeff. I think you're more "brushed-up" on some of the APIs than I am :-)
JeffTucker

Posts: 8,359
Registered: 31-Jan-2006
Re: How to get path to folder thumbnail in index.hht?
Posted: 3 Dec 23, 13:49   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
In this case, I knew I had one oddball skin - Venus - in which I have to do my own iteration, so I could take a quick look to refresh my memory about what it looks like.

And I do always have to check things. "Hmmm, is there a way to have getChildren() return only visible objects? No, drat. I still have to check for 'ncluded' and 'not hidden.'"

I have the sense that there's a way to do that with a lambda expression....

Failing that, a new variation on the method would be nice:

getChildren(Category ofCategory, boolean isVisible)
davidekholm

Posts: 3,975
Registered: 18-Oct-2002
Re: How to get path to folder thumbnail in index.hht?
Posted: 3 Dec 23, 16:15   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
I have the sense that there's a way to do that with a lambda expression....

try
.getChildren(ao -> !ao.isHidden && ao.isIncluded())
JeffTucker

Posts: 8,359
Registered: 31-Jan-2006
Re: How to get path to folder thumbnail in index.hht?
Posted: 3 Dec 23, 16:43   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Even after correcting the typo (needs parens after isHidden), Groovy doesn't like that a bit. It coughs up a parse error.

ETA: Belay that. I was tinkering with Minimal, but Minimal is still using BeanShell.
JeffTucker

Posts: 8,359
Registered: 31-Jan-2006
Re: How to get path to folder thumbnail in index.hht?
Posted: 3 Dec 23, 16:57   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
Not sure if it's better or worse, but the code now becomes:
<%
for(AlbumObject aof : currentFolder.getChildren(ao -> ao.isFolder() && !ao.isHidden() && ao.isIncluded())) {
	Map fvars = aof.getVars();
	fpath = fvars.get("closeupPath");
	fthumb = fvars.get("thumbPath");
	(do whatever it is you're going to do with them)
}
%>
Gets rid of a nesting layer, at least.

But Groovy only - BeanShell has no support for lambda expressions.
Legend
Forum admins
Helpful Answer
Correct Answer

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