support for picking n'th item from the consistent hash

This commit is contained in:
Shish 2018-07-26 00:26:01 +01:00
parent 97a03d8f83
commit 840915c9f0

View file

@ -686,7 +686,7 @@ class Image {
* @param string $_escape
* @return string
*/
public function parse_link_template($tmpl, $_escape="url_escape") {
public function parse_link_template($tmpl, $_escape="url_escape", $n=0) {
global $config;
// don't bother hitting the database if it won't be used...
@ -750,7 +750,8 @@ class Image {
}
// $choice = $flexihash->lookup($pre.$post);
$choice = $flexihash->lookup($this->hash); // doesn't change
$choices = $flexihash->lookupList($this->hash, $n+1); // hash doesn't change
$choice = $choices[$n];
$tmpl = $pre.$choice.$post;
}