From 4a53c021e2f6351a1b57310ff2d8b1e1ebebdad6 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 10 Mar 2004 04:56:20 +0000 Subject: [PATCH] * src/docgen/HtmlDoc.py (add_photo): Enforce given image size. Add optional alt argument. svn: r2997 --- gramps2/ChangeLog | 3 +++ gramps2/src/docgen/HtmlDoc.py | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 41bad53b5..38ce17dec 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -11,6 +11,9 @@ * src/ImageSelect.py (LocalMediaProperties.__init__, GlobalMediaProperties.update_info): Mark translatable string. + * src/docgen/HtmlDoc.py (add_photo): Enforce given image size. + Add optional alt argument. + 2004-03-08 Don Allingham * src/EditPerson.py: TreeView enhancements * src/PeopleModel.py: TreeView enhancements diff --git a/gramps2/src/docgen/HtmlDoc.py b/gramps2/src/docgen/HtmlDoc.py index d528a30b9..1fbe94e6d 100644 --- a/gramps2/src/docgen/HtmlDoc.py +++ b/gramps2/src/docgen/HtmlDoc.py @@ -356,7 +356,7 @@ class HtmlDoc(BaseDoc.BaseDoc): except: raise Errors.ReportError(_("Could not create %s") % fname) - def add_media_object(self,name,pos,x,y): + def add_media_object(self,name,pos,x,y,alt=''): self.empty = 0 size = int(max(x,y) * float(150.0/2.54)) refname = "is%s" % os.path.basename(name) @@ -385,11 +385,18 @@ class HtmlDoc(BaseDoc.BaseDoc): else: xtra = '' - if self.image_dir: - self.f.write('\n' % \ - (self.image_dir,refname,xtra)) + imgsize = img.size() + if imgsize[0] > imgsize[1]: + size_str = "width" else: - self.f.write('\n' % (refname,xtra)) + size_str = "height" + + if self.image_dir: + self.f.write('%s\n' % \ + (self.image_dir,refname,size_str,size,alt,xtra)) + else: + self.f.write('%s\n' + % (refname,size_str,size,alt,xtra)) def start_table(self,name,style): self.tbl = self.table_styles[style]