diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py
index 80eb181ee..ae4c175e6 100644
--- a/gramps/src/WriteXML.py
+++ b/gramps/src/WriteXML.py
@@ -379,8 +379,10 @@ def exportData(database, filename, callback):
for photo in family.getPhotoList():
path = photo.getPath()
- if os.path.dirname(path) == fileroot:
- path = os.path.basename(path)
+ l = len(fileroot)
+ if len(path) >= l:
+ if fileroot == path[0:l]:
+ path = path[l+1:]
g.write(" = l:
+ if fileroot == path[0:l]:
+ path = path[l+1:]
+ g.write(" \n")
g.write(" \n")
g.write(" \n")