Fix: add download stats to kb logs. (#11112)

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu
2025-11-10 13:28:07 +08:00
committed by GitHub
parent bf382e5c4d
commit d207291217
12 changed files with 50 additions and 15 deletions

View File

@ -478,12 +478,14 @@ class Markdown(MarkdownParser):
images = []
# Find all image URLs in text
for url in image_urls:
if not url:
continue
try:
# check if the url is a local file or a remote URL
if url.startswith(('http://', 'https://')):
# For remote URLs, download the image
response = requests.get(url, stream=True, timeout=30)
if response.status_code == 200 and response.headers['Content-Type'].startswith('image/'):
if response.status_code == 200 and response.headers['Content-Type'] and response.headers['Content-Type'].startswith('image/'):
img = Image.open(BytesIO(response.content)).convert('RGB')
images.append(img)
else: