Posts:
4,082
Registered:
18-Oct-2002
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 19:06
in response to: JeffTucker
|
|
|
That's pretty much what I'm already doing, but that generates a theme image for every folder. I don't see how that can be altered to produce a theme image only at the root level.
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.
|
|
|
Posts:
8,062
Registered:
31-Jan-2006
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 19:16
in response to: davidekholm
|
|
|
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.
That code doesn't refer to currentFolder or outputDirectory. Here's what I've got in init.bsh: ThemeImageProcessor custom = new ThemeImageProcessor() {
public String getThemePath(AlbumObject folder) {
return "sa_theme.jpg";
}
};
if(useThemes) {
engine.setThemeImageProcessor(custom);
}
This renames the output file and plants it at the root level of each folder directory.
Sorry if I'm being obtuse (I'm in the middle of a bunch of other stuff at the moment, and not paying enough attention to this), but I just don't see how to alter that to produce only a single theme image.
|
|
|
Posts:
4,098
Registered:
4-Aug-2006
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 19:23
in response to: JeffTucker
|
|
|
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.
That code doesn't refer to currentFolder or outputDirectory. Here's what I've got in init.bsh: ThemeImageProcessor custom = new ThemeImageProcessor() {
public String getThemePath(AlbumObject folder) {
return "sa_theme.jpg";
}
};
if(useThemes) {
engine.setThemeImageProcessor(custom);
}
This renames the output file and plants it at the root level of each folder directory.
Sorry if I'm being obtuse (I'm in the middle of a bunch of other stuff at the moment, and not paying enough attention to this), but I just don't see how to alter that to produce only a single theme image.
See method two in the wiki hel page 
|
|
|
Posts:
8,062
Registered:
31-Jan-2006
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 19:29
in response to: RobM
|
|
|
See method two in the wiki hel page 
I'm sure that works, but ugh. Easier to do a little recursive script in finally.bsh that deletes the theme image everywhere except the top level. It would probably run in less than one second, and would be about 5 lines long.
Edit: In postdir.bsh, you wouldn't even need recursion. Assuming the theme image is at the root of the folder (rather than in slides): if(level > 0) {
File f = new File(outputDirectory + "/sa_theme.jpg");
try {
f.delete();
}
catch(IOException e) {}
}
|
|
|
Posts:
1,974
Registered:
14-Dec-2007
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 19:43
in response to: davidekholm
|
|
|
Well David in one of my first implementations I did put the statement
engine.setThemeImageProcessor(new ThemeImageProcessor());
in index.htt, but in that case the variables themePath, themeWidth and themeHeight did not get a value. I never understood that.
I did that to get in index.htt the possibility to generate or not generate a theme image.
Now I have that line of code in init.bsh, so it is executed only once for an album with a lot of folders. I still don’t understand when and what triggers the theme generation.
I agree with jGromit that it should be possible to call in index.htt a function which could suppress the generation of a theme image.
Edited by: AndreWolff on 25-Nov-2017 20:19
|
|
|
Posts:
4,082
Registered:
18-Oct-2002
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 21:49
in response to: JeffTucker
|
|
|
If you only want a theme image in the root level, just put that code inside init and refer to rootFolder and rootOutputDirectory instead of currentFolder and outputDirectory.
That code doesn't refer to currentFolder or outputDirectory. Here's what I've got in init.bsh: ThemeImageProcessor custom = new ThemeImageProcessor() {
public String getThemePath(AlbumObject folder) {
return "sa_theme.jpg";
}
};
Ah, that's the minimal code you need to use to get the general behavior. If you want to customize it, you can either subclass the ThemeImageProcessor and alter its behavior or use the script referred to as "Method 2" here: http://jalbum.net/help/en/Sample_scripts#Theme_images
Now "Method 2" seems rather lengthy (although being most flexible) so I'd prefer subclassing: Here's how it could look (in init) ThemeImageProcessor custom = new ThemeImageProcessor() {
@Override
public String getThemePath(AlbumObject folder) {
return "sa_theme.jpg";
}
@Override
public void processThemeImage(AlbumObject folder, File outputDir) throws IOException {
if (folder == rootFolder) {
super.processThemeImage(folder, outputDir); //To change body of generated methods, choose Tools | Templates.
}
}
};
engine.setThemeImageProcessor(custom);
|
|
|
Posts:
8,062
Registered:
31-Jan-2006
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
25 Nov 17, 22:08
in response to: davidekholm
|
|
|
Have you actually tried this? I'm guessing not...
Edit: I won't keep you in suspense. There's no @Override in Beanshell, apparently. The error message is actually, "Encountered O after @," or something to that effect.
Just killing those two lines, it seems to work.
|
|
|
Posts:
4,082
Registered:
18-Oct-2002
|
|
|
Re: Theme Images: option to suppress them for subfolders
Posted:
26 Nov 17, 00:10
in response to: JeffTucker
|
|
|
Have you actually tried this? I'm guessing not...
Edit: I won't keep you in suspense. There's no @Override in Beanshell, apparently. The error message is actually, "Encountered O after @," or something to that effect.
Just killing those two lines, it seems to work.
I simply "tested" the code in NetBeans (using its on-the-fly code verification, assuming you had compiled code too. Yes, as you figured out one has to dump the @Override annotations to make it work in BeanShell. Oh God I wish they updated BeanShell.
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|