|
|
@@ -86,10 +86,14 @@ def replace_image_with_base64(markdown_text, image_dir_path):
|
|
|
# 替换图片链接
|
|
|
def replace(match):
|
|
|
relative_path = match.group(1)
|
|
|
- full_path = os.path.join(image_dir_path, relative_path)
|
|
|
- base64_image = image_to_base64(full_path)
|
|
|
- return f''
|
|
|
-
|
|
|
+ # 只处理以.jpg结尾的图片
|
|
|
+ if relative_path.endswith('.jpg'):
|
|
|
+ full_path = os.path.join(image_dir_path, relative_path)
|
|
|
+ base64_image = image_to_base64(full_path)
|
|
|
+ return f''
|
|
|
+ else:
|
|
|
+ # 其他格式的图片保持原样
|
|
|
+ return match.group(0)
|
|
|
# 应用替换
|
|
|
return re.sub(pattern, replace, markdown_text)
|
|
|
|