OSDN Git Service

fix: use thumbnail when figure size is smaller than thumbnail size
[otptools/otptools.git] / wp_imgswap.py
index 85d430a..699862b 100644 (file)
@@ -68,6 +68,7 @@ def replace_img_tag(line, tagstr, path):
     attrs = htmltaglib.parse_attributes(tagstr)
     (root, ext) = os.path.splitext(os.path.basename(path))
 
+    filename = ""
     if 'width' in attrs:
         (w, h) = _get_png_geom(path)
         if int(w) > image_width:
@@ -79,7 +80,6 @@ def replace_img_tag(line, tagstr, path):
             attrs['width'] = str(w)
             filename = '''%s%s''' % (root, ext)
 
-
     wp_image_url = '''%s%s''' % (image_dir, filename)
     attrs['src'] = wp_image_url
         # if tag has 'alt' attribute, use it