Yeah-yeah. I guess Thewlis just forgot to mention in his well commented example this little "school name = folder name" thing which he coded by himself without a doubt.
So he did, you want to sue him or something?
This is the part that is responsible for the image loading I think:
def get_lesson_image(self):
"""
Returns an image for the lesson.
"""
if self.image is not None: return self.image
else:
images = list()
if self.type in os.listdir(content_path("schools")):
for file in os.listdir(content_path("schools/%s"%self.type)):
images.append("schools/%s/%s"%(self.type, file))
if len(images) > 0: self.image = choice(images)
else: self.image = "gfx/interface/images/no_image.png"
return self.image
It already works like I suggested:
1) It checks is there is a single image assigned to schools.
2) If not found, it will try to find a folder with the name of a lesson and select a random pic from there.
3) If that fails as well, it will use a no image found picture as last resort.
==
*So I think you an add "image": "path/image.jpg" to json and it will overwrite the folder
or you can create a folder with just one image in it.
**This was definitely not coded by me and I created original schools before Matt joined the team and told us about JSON and how it is more convenient to structure data for Python than XML we were using.