(I don't know how goodl is your PHP knowledge and 4images itself, so my following tip might not be very usefull to you)I think the easiest way (easiest within the hardest
) to do this would be add a new field in 4images_images table. As an example lets call it image_related
In that field we'll store image id of the "main" image.
Now, when we change each database query related to IMAGES_TABLE in 4images files so it would exclude the images with not empty image_related field i.e.
$sql = " SELECT *
FROM " . IMAGES_TABLE . "
WHERE NOT image_related";
There are quiet a few places where such condition needed to be added.
And finally in details.php we query database for any related images:
$sql = " SELECT *
FROM " . IMAGES_TABLE . "
WHERE image_related=" . $image_id;
Good luck