• Hi Guys,

    Great plugin. Is there perhaps a way of randomising the order of images when using the gallery shortcode for a particular album? I couldn’t find anything related o that in the FAQs or forum. I’m using the plugin to access Google Photo galleries.

    Thanks in advance

    • This topic was modified 11 months, 1 week ago by primesitesco.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Sayontan Sinha

    (@sayontan)

    Randomization will need to be supported by the source platform’s API for me to include it in Photonic. Google Photos has no concept of randomization or sorting, which means that Photonic cannot provide that feature.

    Other platforms may have similar features, but Google Photos does not.

    Thread Starter primesitesco

    (@primesitesco)

    Hi Sayontan, thanks for getting back to me.

    Is there perhaps a hook in your plugin I can use to get access to the list of images returned from Google, prior to it being displayed on the front? I might be able to write it into an array, shuffle() it and then return the randomised array to then be written to the front-end.

    I.e. not relying on the provider to randomise, but doing it locally after the images have been retrieved.

    Looking forward to hearing your thoughts.

    • This reply was modified 11 months, 1 week ago by primesitesco.
    Plugin Author Sayontan Sinha

    (@sayontan)

    There isn’t currently any provision for this, though adding a hook is not too difficult.

    That being said, this is a slippery slope. Basically, when a platform does not support this natively, it will always return a predetermined set of data. Let’s say, you had a Google Photos album of 500 photos. Google will always batch and return 100 photos in the same sequence (it cannot return more than 100 photos in one shot). Even if you randomize the photos, they will always be from the first set of 100. There is no way to get around this.

    The reason I am hesitant to offer capabilities beyond what are supported by a platform directly is that it is easy to get sucked into high degree of customizations. E.g. a subsequent request might want me to first fetch all photos from a Google album if the count is higher than 100 (which is highly inefficient and degrades user experience), then apply the sort.

    I will look into offering a hook in the next iteration.

    Thread Starter primesitesco

    (@primesitesco)

    That all makes sense, and I’m definitely not trying to make more work for you. The idea I had was to initiate the fetch from Google Photos with a randomised page number (say between 0-9) and then randomise the returned set of images before outputting. It’s for a specific use case we have. If adding a hook which might expose the ability to specify the requested page/batch number, it would be great. Then it would provide a closer approximation to randomisation. Thanks in advance.

    • This reply was modified 11 months, 1 week ago by primesitesco.
    Plugin Author Sayontan Sinha

    (@sayontan)

    That’s the thing… Google’s API doesn’t support page-based pulls. Instead, for every data set that you pull, you are given a token, which you have to use to fetch the next data set. You cannot pass an arbitrary page number and make it return photos from that page (unlike Flickr or SmugMug). So, if you wanted photos from the 5th page, the only way to do that for Google is to make 5 sequential calls real-time (Google will not allow you to cache either), then perform the random sorting on the 5th data set. This data pull itself will take several seconds to execute.

    Thread Starter primesitesco

    (@primesitesco)

    Ah, I see, thanks for the explanation. Well if randomising the first 100 is all that’s possible with a hook, I’ll take it. If that hook is not too much trouble it would be well worth it to have access to. Thanks for your very fast responses. Appreciate it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Random image order’ is closed to new replies.