From 2b9333a8c78d5b388798d865de61a19c27a9438c Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 9 May 2023 10:08:54 +0200 Subject: [PATCH] update image Alt Text when modified, fix #267 --- server/api/controller/event.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/api/controller/event.js b/server/api/controller/event.js index e9330d4d..4d017652 100644 --- a/server/api/controller/event.js +++ b/server/api/controller/event.js @@ -454,11 +454,18 @@ const eventController = { }] } else if (!body.image) { eventDetails.media = [] - } else if (body.image_focalpoint && event.media.length) { + } + + if (body.image_focalpoint && event.media.length) { let focalpoint = body.image_focalpoint ? body.image_focalpoint.split(',') : ['0', '0'] focalpoint = [parseFloat(parseFloat(focalpoint[0]).toFixed(2)), parseFloat(parseFloat(focalpoint[1]).toFixed(2))] eventDetails.media = [{ ...event.media[0], focalpoint }] // [0].focalpoint = focalpoint } + + if (body.image_name && event.media.length && event.media[0].name !== body.image_name) { + eventDetails.media[0].name = body.image_name || body.title || '' + } + await event.update(eventDetails) // find or create the place