OK, I am almost there…I have all the pieces, I just need to put them together. Here’s what my pseudo-code looks like:
First, get the category id and page:
$cat_id_array = explode("C", "{segment_3}");
$cat_id = cat_id_array[1];
$page_array = explode("P", "{segment_3}");
$page = page_array[1];
Then get the entry ids:
$query = $DB->query("SELECT entry_id FROM exp_gallery_entries WHERE cat_id = $cat_id");
if ($query->num_rows > 0)
{
foreach($query->result as $row)
{
array_push($entry_ids, {entry_id});
}
}
Then do the calculation to get the correct index and get the correct image URL:
$index = ($page - 1) * images_per_page;
$query = $DB->query("SELECT filename, extenstion FROM exp_gallery_entries WHERE entry_id = $entry_ids[$index]");
$img_url = "{site_url}/{gallery_name}/{category_name}/{filename}.{extension}
And that should do it, I think. Off to try.