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


Permlink Replies: 6 - Pages: 1 - Last Post: 29 Jul 21, 20:50 Last Post By: AndreWolff Threads: [ Previous | Next ]
AndreWolff

Posts: 1,158
Registered: 14-Dec-2007
Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 12:26
 
  Click to reply to this thread Reply
To implement srcsets in the new version of the PhotoSwipe skin, I need to know the dimensions of the largest image in the set.

I use now this:
 data-pswp-width="${imageWidth}" data-pswp-height="${imageHeight}"
but that are not the dimensions of the largest image in the set, unless the largest scale is 1.

Is there a simple method to get the dimensions of the largest image in the set?

I have another problem for the implementation:

The current implementation of the srcsets generates a srcset string with the largest image first and with the smallest image last.
For the PhotSwipe implementation, The smallest image should be first and the larges image last.
Is there a simple metod to get the current sequence reversed?

BTW: How can I enlarge the size of the image dimension printed in the middle of the image if I use FINEST as logging level? The text is for some sizes unreadable for my eyes has you can see in this test album.

Edited by: AndreWolff on 29 Jul 2021, 12:38

Edited by: AndreWolff on 29 Jul 2021, 12:48
RobM

Posts: 3,834
Registered: 4-Aug-2006
Re: Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 15:45   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Getting the largest variant was discussed in the 24 beta thread, which you participated in. The answer, however, is currentObject.getRenderer().getCloseupRenditions().get(0).getWidth();

For your second question, read the renditions list and create your own list in reverse order.

Third question, have you tried using the text image filter?
AndreWolff

Posts: 1,158
Registered: 14-Dec-2007
Re: Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 16:40   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
Getting the largest variant was discussed in the 24 beta thread, which you participated in. The answer, however, is currentObject.getRenderer().getCloseupRenditions().get(0).getWidth();

For your second question, read the renditions list and create your own list in reverse order.

Sorry Rob, I am not a JAVA programmer, so I do not understand that.
I need ready to copy code!
Third question, have you tried using the text image filter?
No I just use Davids Logging level FINEST recipe.
RobM

Posts: 3,834
Registered: 4-Aug-2006
Re: Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 18:11   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I use
//Get the biggest file from the srcSet
String biggest = "slides/" + currentObject.getRenderer().getCloseupRenditions().get(0).getEncodedName();
Then I just use
${biggest}
where I need to.
AndreWolff

Posts: 1,158
Registered: 14-Dec-2007
Re: Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 18:19   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
We I use now:
<ja:if exists="imageSrcset">
<% 
useSrcSet=true; 
largestWidth = currentObject.getRenderer().getCloseupRenditions().get(0).getWidth();
largestHeight = currentObject.getRenderer().getCloseupRenditions().get(0).getHeight();
System.out.println("largestWidth: " + largestWidth + " largestHeight: " + largestHeight); 
%>
data-pswp-srcset="${imageSrcset}" </ja:if>

I think this was your original proposal!
RobM

Posts: 3,834
Registered: 4-Aug-2006
Re: Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 18:54   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
To get them in reverse order, except natural size will always be first, so you need to adjust for that.
int size = currentObject.getRenderer().getCloseupRenditions().size();
System.out.println("size " + size);
for (int i = size-1; i >= 0; i--) {
	System.out.println(currentObject.getRenderer().getCloseupRenditions().get(i).getEncodedName()) ;
}
AndreWolff

Posts: 1,158
Registered: 14-Dec-2007
Re: Srcsets / Variants: How to get the dimensions of the largest image?
Posted: 29 Jul 21, 20:50   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Rob, thanks for your code.
It appears that the order is not important,

The way srcsets are implemented in the new Photoswipe gallery is unique I think:
You see the images changing if you do a pinch zoom, see this test album.

I did not see this in any jAlbum skin supporting srcsets!
Legend
Forum admins
Helpful Answer
Correct Answer

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