fix(docparser): preserve standalone image uploads from icon filter
When the uploaded file is itself an image, the image reference now carries an IsOriginal flag so ResolveAndStore skips the small-icon size filter. Otherwise small standalone images (e.g. avatars below 64x64) were silently dropped before reaching multimodal OCR/caption processing.
This commit is contained in:
@@ -98,6 +98,7 @@ func imageToResult(fileName string, data []byte) *types.ReadResult {
|
|||||||
OriginalRef: safeRef,
|
OriginalRef: safeRef,
|
||||||
MimeType: mime,
|
MimeType: mime,
|
||||||
ImageData: data,
|
ImageData: data,
|
||||||
|
IsOriginal: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -170,6 +171,7 @@ func ensureOriginalImageRef(req *types.ReadRequest, mdContent string, imageRefs
|
|||||||
OriginalRef: refPath,
|
OriginalRef: refPath,
|
||||||
MimeType: mime,
|
MimeType: mime,
|
||||||
ImageData: req.FileContent,
|
ImageData: req.FileContent,
|
||||||
|
IsOriginal: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
return mdContent, imageRefs
|
return mdContent, imageRefs
|
||||||
|
|||||||
@@ -126,8 +126,11 @@ func (r *ImageResolver) ResolveAndStore(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter out small icons and decorative images
|
// Filter out small icons and decorative images. Skip the filter
|
||||||
if isIconImage(ref.ImageData) {
|
// when the reference is the originally uploaded file itself, so
|
||||||
|
// that a standalone image upload is never silently dropped even
|
||||||
|
// if its dimensions are below the icon threshold.
|
||||||
|
if !ref.IsOriginal && isIconImage(ref.ImageData) {
|
||||||
// Remove the image reference from markdown entirely
|
// Remove the image reference from markdown entirely
|
||||||
markdown = markdown[:m[0]] + markdown[m[1]:]
|
markdown = markdown[:m[0]] + markdown[m[1]:]
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ type ImageRef struct {
|
|||||||
MimeType string
|
MimeType string
|
||||||
StorageKey string
|
StorageKey string
|
||||||
ImageData []byte // inline image bytes (universal fallback for cross-machine deployments)
|
ImageData []byte // inline image bytes (universal fallback for cross-machine deployments)
|
||||||
|
// IsOriginal marks references that point to the originally uploaded file
|
||||||
|
// itself (e.g. when the user uploads a standalone image). Such references
|
||||||
|
// must not be dropped by the icon/size filter — otherwise a small image
|
||||||
|
// upload would be silently discarded before multimodal processing.
|
||||||
|
IsOriginal bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParserEngineInfo describes a registered parser engine.
|
// ParserEngineInfo describes a registered parser engine.
|
||||||
|
|||||||
Reference in New Issue
Block a user