From 1ed9467221224751bbfcf30b960334b0abe3bd29 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 21 Jul 2020 22:40:46 +0200 Subject: [PATCH] Use 'image' as key for a new image if it is available --- Logic/OsmImageUploadHandler.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Logic/OsmImageUploadHandler.ts b/Logic/OsmImageUploadHandler.ts index 3cabdbc40..cd242c777 100644 --- a/Logic/OsmImageUploadHandler.ts +++ b/Logic/OsmImageUploadHandler.ts @@ -48,12 +48,18 @@ export class OsmImageUploadHandler { title: title, description: description, handleURL: function (url) { - let freeIndex = 0; - while (tags["image:" + freeIndex] !== undefined) { - freeIndex++; + + let key = "image"; + if (tags["image"] !== undefined) { + + let freeIndex = 0; + while (tags["image:" + freeIndex] !== undefined) { + freeIndex++; + } + key = "image:" + freeIndex; } - console.log("Adding image:" + freeIndex, url); - changes.addChange(tags.id, "image:" + freeIndex, url); + console.log("Adding image:" + key, url); + changes.addChange(tags.id, key, url); self._slideShow.MoveTo(-1); // set the last (thus newly added) image) to view }, allDone: function () {