Topic: Get Current Image on Mobile View

Hi There

I'd like to be able to get the current image when the mobile view is being displayed but there's no rhyme or reason it appears as to what the various div tags are called for the imgs and I can't tell whether there's a javascript method that would do this for me?

Naturally I want to be able to detect if the thumbnail view is visible or not as well.

Thanks a lot
Ian H

Re: Get Current Image on Mobile View

I do not think this is easily achievable (if at all) for the Mobile Player.
The SimpleViewer Pro API has the required methods but this will work for the Flash Player only.
I think the solution would lie in the modification of the 'simpleviewer.js' file.
However, as part of the 'svcore' folder, such modifications are not supported (and the file is packed so it is effectively uneditable anyway).
If I think of a workable solution to this problem, I will post back here.

Steven Speirs
SimpleViewer Support Team.

Re: Get Current Image on Mobile View

Whoops! I submitted my reply from my iPhone while putting my 8 month old daughter to bed and wasn't paying attention and reported on the link instead of replying!!! Please disregard that 'report'.

Here's what I actually wrote...

Thanks for the prompt reply. I was wandering, would the only visible img tag be the current image within a certain div tag? If so I can infer the current img. If that div tag is missing when the thumbnails are up or multiple img tags are visible then I can infer thumbnail mode. Something like that?

All help great appreciated!

Thanks
Ian H

Re: Get Current Image on Mobile View

I do not know but perhaps Firebug and/or trial and error would be the way to proceed.

Steven Speirs
SimpleViewer Support Team.

Re: Get Current Image on Mobile View

Thanks for the suggestion, yes that looks like a useful tool.  However, I have examined the structure using Safari's developer elements view and my solutions was as follows:

* find all img tags within the div tag containing the gallery (sv_div.getElementsByTagName("img"))
* look through and find the visible ones
* you then have two or three.  Three if you are anywhere within the gallery and two if at the beginning and the end.
* If you see two visible images, then the first of the visible images is the current image (see below)
* If you see three, then the 2nd image, the middle image is the visible image
* Any other number and you're on the thumbnail view

So I had hoped to determine when at two images if you were at the beginning or the end, but I'd probably need firebug for this or some more educated guess work. I've solved this by always adding a duplicate of the last image to the end of the gallery.  It's not an ideal solution, but it works, otherwise you cannot 'select' the last image.

I had hoped to look at the offsetLeft position for the img tags but they are identical, so I presume they sit in a div that is offscreen left and right and comparing these positions would allow me to infer that, yes, img 0 is on screen (at the beginning) or no it's img 1 (the last img in the gallery).

Of course if your thumbnail view can ever show only two or three images, then this somewhat falls down there as well, so I'll probably have to look to see if the width and height of the first img are the same, as my images are not square, but the thumbnails are.

It's all a bit hacky, but it seems to work reasonably well enough.  That said, some means of identifying the current image for the non-flash view would be greatly appreciated!!

Thanks a lot
Ian H

Last edited by IanH (2011-06-08 09:00:17)

Re: Get Current Image on Mobile View

I'm glad you've been able to work something out.
Thank you for posting your findings so far.

That said, some means of identifying the current image for the non-flash view would be greatly appreciated!!

Please post features requests in this thread so that they are not overlooked. Thanks.

Steven Speirs
SimpleViewer Support Team.