Добавлено сохранение подписи под изображением.

This commit is contained in:
anibilag 2025-05-02 23:51:26 +03:00
parent d3ef4f6f45
commit 35791b4308
2 changed files with 3 additions and 1 deletions

View File

@ -364,6 +364,7 @@ export async function importArticles(req: AuthRequest, res: Response) : Promise<
// Шаг 3: Обработка массива images
let updatedContent = newArticle.content;
if (article.images && Array.isArray(article.images) && article.images.length > 0) {
const folder = `articles/${newArticle.id}/images`;
const uploadedImageUrls: string[] = [];
@ -405,7 +406,7 @@ export async function importArticles(req: AuthRequest, res: Response) : Promise<
uploadedImageUrls.forEach((uploadedUrl, index) => {
if (uploadedUrl) {
const placeholder = `{{image${index + 1}}}`;
const imgTag = `<img src="${uploadedUrl}" alt="" scale="0.9" style="transform: scale(0.9)">`;
const imgTag = `<img src="${uploadedUrl}" alt="${article.imageSubs[index]}" data-scale="0.9" data-caption="${article.imageSubs[index]}" style="width: 90%">`;
const regex = new RegExp(placeholder, 'g');
updatedContent = updatedContent.replace(regex, imgTag);
}

View File

@ -9,6 +9,7 @@ export interface Article {
author: Author;
coverImage: string;
images?: string[];
imageSubs: string[];
gallery?: GalleryImage[];
publishedAt: string;
readTime: number;