Commit 19e8df4a by murtaugh

ensure |thumb option on fixed images

parent 095fbe8e
......@@ -12,6 +12,16 @@ def filetest (p):
return False
return True
def ensure_image_option (opts, newopts="thumb"):
if opts == None:
opts = ""
opts = opts.split("|")
opts = [x for x in opts if x]
for nop in newopts.split("|"):
if nop not in opts:
opts.append(nop)
return "|" + "|".join(opts)
def fixurlfilelinks (src, wiki, timestamp=None, phpuploader=None, user=None):
if timestamp == None:
timestamp = datetime.now().strftime("%Y/%m/%d")
......@@ -23,7 +33,7 @@ def fixurlfilelinks (src, wiki, timestamp=None, phpuploader=None, user=None):
print ("URL failed {0} leaving link as is: {1}".format(m.group(1), m.group(0)), file=sys.stderr)
return m.group(0)
else:
return "[[{0}{1}]]".format(page.name, m.group(2) or "")
return "[[{0}{1}]]".format(page.name, ensure_image_option(m.group(2), "thumb"))
return re.sub(r"\[\[(?:File|Fichier|Image)\:(https?\://.+?)(\|.*?)?\]\]", linksub, src)
def fixlinks (page, wiki, phpuploader=None, user=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment