This question is answered.


Permlink Replies: 7 - Pages: 1 - Last Post: 8 Apr 22, 19:36 Last Post By: RobM Threads: [ Previous | Next ]
AndreWolff

Posts: 1,157
Registered: 14-Dec-2007
How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 14:20
 
  Click to reply to this thread Reply
I used this code in index.htt to detect whether original images could be downloaded:
<% orgImages = false; %>
<ja:fileiterator start="0" ><% if (originalPath != void && originalPath != null && (fileCategory == Category.image))  {  orgImages = true; }  %> </ja:fileiterator>
But now has this code has been moved to a template file called from init.bsh, so that code gives now a crash.

So my question is:

How can I see in init.bsh whether original images can be downloaded?
RobM

Posts: 3,946
Registered: 4-Aug-2006
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 15:03   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
This is exactly the same issue as your previous post. If you really need to do this in init.bsh you need to use a for AlbumObject loop, not a ja file Iterator.
JeffTucker

Posts: 7,955
Registered: 31-Jan-2006
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 15:04   in response to: AndreWolff in response to: AndreWolff
Correct
  Click to reply to this thread Reply
In effect, you can't. You can detect the linking choice, like Link to originals via scaled images
linkOvS = engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS_VIA_SCALED);
But the user might have tagged one or two individual images with Use original or Include original, and you can't know about that until that image is actually processed during the album build.
AndreWolff

Posts: 1,157
Registered: 14-Dec-2007
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 15:14   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
This is exactly the same issue as your previous post. If you really need to do this in init.bsh you need to use a for AlbumObject loop, not a ja file Iterator.
I know, but I have no idea how to de that in a AlbumObject loop.
If you know it, please show the code.
AndreWolff

Posts: 1,157
Registered: 14-Dec-2007
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 15:18   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
In effect, you can't. You can detect the linking choice, like Link to originals via scaled images
linkOvS = engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS_VIA_SCALED);
But the user might have tagged one or two individual images with Use original or Include original, and you can't know about that until that image is actually processed during the album build.

So the best code is
orgImages= engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS) || engine.getImageLinking().equals(AlbumBean.LINK_ORIGINALS_VIA_SCALED)

I only use this for the hint text, so if there are exceptions it is not a problem.

Thanks for the code.
RobM

Posts: 3,946
Registered: 4-Aug-2006
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 16:09   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
What are you really trying to do? Why move your original code and why can’t you move it back?
AndreWolff

Posts: 1,157
Registered: 14-Dec-2007
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 16:30   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
What are you really trying to do? Why move your original code and why can’t you move it back?
With an album with 100 folders, that part of code was 101 times loaded because it was in index.html.
With the new template all 101 index.html files are smaller, so the whole album takes less space and loads faster.
RobM

Posts: 3,946
Registered: 4-Aug-2006
Re: How to detect in init.bsh whether original images are available?
Posted: 8 Apr 22, 17:04   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
RobM wrote:
What are you really trying to do? Why move your original code and why can’t you move it back?
With an album with 100 folders, that part of code was 101 times loaded because it was in index.html.
With the new template all 101 index.html files are smaller, so the whole album takes less space and loads faster.
But if a single image has ‘use original’ or ‘include original’ set how do you know which one to apply the download to on the index page?

Regardless, you could in index.htt use
<%!
boolean orgImages = false;
CheckOriginals(AlbumObject folder, boolean hasOriginal) {
for(ao: folder.getChildren()) {
if(ao.isFolder()) hasOriginal = CheckOriginals(ao, hasOriginal);
else {
your code to check for original path with
if original exists set hasOriginal to true
}
}
orgImages = checkOiginals(rootFolder, false);
%>
Not tested.

Edited by: RobM on 8 Apr 2022, 18:34
added the assignment of the result of the recursive call
Legend
Forum admins
Helpful Answer
Correct Answer

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