Hello Simon,
First of all I need to comment that one of the lines is not working properly in your script (actually, it's my fault as I have originally posted that line before in some scripts here):
("jpg" or "jpeg" or "tif" or "png") in photo.lower():
should be corrected to the following, for example:
photo.lower()[-3:] in ["jpg", "jpeg","tif","png"]:
As for the .loadReference() function - it is an equivalent to the Reference pane -> Import button. So you need to use chunk.importMarkers() function instead.