Note that I have just updated XFMG's download to fix this, but you can fix it by changing library/XenGallery/ControllerPublic/Comment.php's line:
Code:
$page = floor($commentsWithPosition[$commentId]['position'] / XenForo_Application::getOptions()->xengalleryMaxMediaCommentsPerPage) + 1;
to:
Code:
$page = floor($commentsWithPosition[$commentId]['position'] / XenForo_Application::getOptions()->xengalleryMaxCommentsPerPage) + 1;