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


Permlink Replies: 16 - Pages: 2 [ 1 2 | Next ] - Last Post: 09-Mar-2017 13:13 Last Post By: davidekholm Threads: [ Previous | Next ]
Dschuwi

Posts: 457
Registered: 12-Nov-2003
User variables
Posted: 04-Mar-2017 12:06
 
  Click to reply to this thread Reply
A user is manually changing maxImageWidth by setting a user variable for individual images.

This crashes album generation when performing calculations with it, since the variable is of type String in this case.

Any ideas how to solve this?
RobM

Posts: 3,066
Registered: 4-Aug-2006
Re: User variables
Posted: 04-Mar-2017 13:09   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
You could use
if (variable instanceof Integer)
or instance of String, to test what you have. But maybe jAlbum core should convert those specific user variables to match the values of the normal image bounds?
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: User variables
Posted: 04-Mar-2017 15:14   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
You could use
if (variable instanceof Integer)
or instance of String, to test what you have. But maybe jAlbum core should convert those specific user variables to match the values of the normal image bounds?

I tried this, it works basically to test the user variable, which is of type String. However, other users might come up with other ideas to overrule jAlbum and/or the skin, so I would end up to check every possible variable if it still is of the type CA2 expects under regular circumstances.

Strange though, I cannot determine the type of maxImageWidth as provided by jAlbum that way. It is not String, Integer, Float, Long or Double - what is it?
jGromit

Posts: 7,279
Registered: 31-Jan-2006
Re: User variables
Posted: 04-Mar-2017 15:32   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
Dschuwi wrote:
Strange though, I cannot determine the type of maxImageWidth as provided by jAlbum that way. It is not String, Integer, Float, Long or Double - what is it?

It's a bsh.Primitive. Not much help, I know, but there you have it!

Edit: A variable declared under Settings > Advanced > User Variables is the same type. But a variable declared for an individual image comes back as a String. Something for David to ponder....
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: User variables
Posted: 04-Mar-2017 15:47   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Well, this is at least some knowledge :-)

Back to the the initial problem: Is there a way for the user to defne his user variable as Integer, or does the skin have to catch this, indeed? I.e. the skin has to provide support for his special user case?
jGromit

Posts: 7,279
Registered: 31-Jan-2006
Re: User variables
Posted: 04-Mar-2017 16:14   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
Dschuwi wrote:
Is there a way for the user to defne his user variable as Integer....

As far as I can tell, no. If the skin sets up a custom UI, of course, it can control the data types, but when using the built-in image-level variables, it looks like you're stuck with a String.
RobM

Posts: 3,066
Registered: 4-Aug-2006
Re: User variables
Posted: 04-Mar-2017 16:29   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
Dschuwi wrote:
I tried this, it works basically to test the user variable, which is of type String. However, other users might come up with other ideas to overrule jAlbum and/or the skin, so I would end up to check every possible variable if it still is of the type CA2 expects under regular circumstances.
Since maxImageWidth, for example, is a core variable I think the value returned from its use as a custom variable should be of the same type as the maxImageWidth from the settings page. Skin variables though are up to the skin developer to deal with.
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: User variables
Posted: 04-Mar-2017 17:27   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:

Since maxImageWidth, for example, is a core variable I think the value returned from its use as a custom variable should be of the same type as the maxImageWidth from the settings page.


I agree.
davidekholm

Posts: 3,551
Registered: 18-Oct-2002
Re: User variables
Posted: 06-Mar-2017 16:58   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
Dschuwi wrote:
A user is manually changing maxImageWidth by setting a user variable for individual images.

This crashes album generation when performing calculations with it, since the variable is of type String in this case.

Any ideas how to solve this?


Does he want to mix panoramics with ordinary images? In that case, simply set image bounds to an extreme, like 10000x800 for instance.
jGromit

Posts: 7,279
Registered: 31-Jan-2006
Re: User variables
Posted: 06-Mar-2017 17:39   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Does he want to mix panoramics with ordinary images? In that case, simply set image bounds to an extreme, like 10000x800 for instance.

That's not always feasible.

Take Matrix, for example. Normal slide images are fully responsive, so you want image bounds like 1600x750. But pano's have a fixed height, so you don't want to use 750 as the height. For a pano, you might want image bounds of 10000x400. Applying those extreme bounds to the regular images makes them all too short to take advantage of the viewport, but using 10000x750 makes the pano too tall.

(Edit: BTW, the fact that it's a String doesn't cause any problems in Matrix because I'm just using the value to plug into the HTML. I'm not actually doing any math with it.)

Edited by: jGromit on 06-Mar-2017 12:45
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: User variables
Posted: 06-Mar-2017 23:23   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:

Does he want to mix panoramics with ordinary images? In that case, simply set image bounds to an extreme, like 10000x800 for instance.


Yes, but then these image bounds would apply to all other images as well.

I believe it is a legit request to change bounds (or whatever variable) on a per image basis.

The point is: jAlbum makes it possible by manually setting user variables which override album wide settings, which is great. However, maxImageWidth provided by jAlbum is a number, overridden by a user variable it is a string though, which seems odd.

So I second the idea that any user varible which overrides a jAlbum variable should automatically be of the same type.

I have overcome the crash problem meanwhile and let CA2 perform a test on this variable, so panoramic image support is going to be a "feature" of the next release ;-)
jGromit

Posts: 7,279
Registered: 31-Jan-2006
Re: User variables
Posted: 06-Mar-2017 23:37   in response to: Dschuwi in response to: Dschuwi
 
  Click to reply to this thread Reply
Dschuwi wrote:
...panoramic image support is going to be a "feature" of the next release ;-)



"New! Improved!! Now crash-free!!!!"
AndreWolff

Posts: 1,701
Registered: 14-Dec-2007
Re: User variables
Posted: 08-Mar-2017 11:09   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Does he want to mix panoramics with ordinary images? In that case, simply set image bounds to an extreme, like 10000x800 for instance.
I agree with jGromit: this is not a good solution.

Please look again to my requests for panoramic pictures:

http://jalbum.net/forum/thread.jspa?messageID=297713&#297713

http://jalbum.net/forum/thread.jspa?threadID=49452&start=0&tstart=0
davidekholm

Posts: 3,551
Registered: 18-Oct-2002
Re: User variables
Posted: 08-Mar-2017 11:37   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
The upcoming jAlbum version now tries to set proper data types for image specific user variables. Here's the mapping that's currently performed:
A value that can be represented as a double number is converted to double
A values that can be represented as an integer is converted to int
If neither of these conditions holds, the value is kept as a String.

If you want to try the beta, it's here: http://jalbum.net/download/beta/jalbum-core.jar
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: User variables
Posted: 08-Mar-2017 12:16   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Great, it works like a charm, tested for my special use case. Thanks!
Legend
Forum admins
Helpful Answer
Correct Answer

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