fix: use alt -> title -> filename

This commit is contained in:
2026-02-15 09:31:42 +01:00
parent 416a7ad5d3
commit b730f12ba0
4 changed files with 16 additions and 5 deletions

View File

@@ -201,10 +201,13 @@ export class ImportAnalysisEngine {
// - Otherwise, use the original image src
const imageUrl = hrefIsImage ? href : imgSrc;
// Derive alt text: use image alt if not empty, otherwise extract filename from the URL
// Derive alt text: prefer alt, then title, then filename
let altText = imgAlt.trim();
if (!altText) {
// Extract filename from the image URL
altText = imgTitle.trim();
}
if (!altText) {
// Extract filename from the image URL as last resort
const urlPath = imageUrl.split('?')[0]; // Remove query string
const filename = urlPath.split('/').pop() || '';
altText = filename;

View File

@@ -111,10 +111,13 @@ export class ImportExecutionEngine extends EventEmitter {
// - Otherwise, use the original image src
const imageUrl = hrefIsImage ? href : imgSrc;
// Derive alt text: use image alt if not empty, otherwise extract filename from the URL
// Derive alt text: prefer alt, then title, then filename
let altText = imgAlt.trim();
if (!altText) {
// Extract filename from the image URL
altText = imgTitle.trim();
}
if (!altText) {
// Extract filename from the image URL as last resort
const urlPath = imageUrl.split('?')[0]; // Remove query string
const filename = urlPath.split('/').pop() || '';
altText = filename;