Index: /trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java	(revision 19288)
+++ /trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java	(revision 19289)
@@ -169,5 +169,5 @@
             if (infoToAdd != null) {
                 layer = ImageryLayer.create(infoToAdd);
-                getLayerManager().addLayer(layer);
+                getLayerManager().addLayer(layer, false);
                 AlignImageryPanel.addNagPanelIfNeeded(infoToAdd);
             }
Index: /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 19288)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 19289)
@@ -27,5 +27,6 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.time.Instant;
 import java.util.ArrayList;
@@ -292,8 +293,8 @@
 
         try {
-            if ("file".equalsIgnoreCase(new URL(tileSource.getBaseUrl()).getProtocol())) {
+            if ("file".equalsIgnoreCase(new URI(tileSource.getBaseUrl()).toURL().getProtocol())) {
                 tileLoader = new OsmTileLoader(this);
             }
-        } catch (MalformedURLException e) {
+        } catch (URISyntaxException | MalformedURLException e) {
             // ignore, assume that this is not a file
             Logging.log(Logging.LEVEL_DEBUG, e);
@@ -515,7 +516,7 @@
         if (tile != null) {
             try {
-                new Notification(HttpClient.create(new URL(tile.getUrl() + '/' + request))
+                new Notification(HttpClient.create(new URI(tile.getUrl() + '/' + request).toURL())
                         .connect().fetchContent()).setIcon(JOptionPane.INFORMATION_MESSAGE).show();
-            } catch (IOException ex) {
+            } catch (URISyntaxException | IOException ex) {
                 Logging.error(ex);
             }
@@ -1874,4 +1875,7 @@
     @Override
     public void visitBoundingBox(BoundingXYVisitor v) {
+        if (this.getInfo() != null) {
+            v.visit(this.getInfo().getBounds());
+        }
     }
 
Index: /trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java	(revision 19288)
+++ /trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java	(revision 19289)
@@ -8,4 +8,5 @@
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import java.util.Arrays;
 import java.util.List;
 
@@ -13,10 +14,16 @@
 import org.junit.jupiter.api.Test;
 import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
+import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.imagery.ImageryInfo;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.projection.ProjectionRegistry;
 import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.gui.layer.TMSLayer;
 import org.openstreetmap.josm.gui.layer.WMSLayer;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
 import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
+import org.openstreetmap.josm.testutils.annotations.Main;
 import org.openstreetmap.josm.testutils.annotations.OsmApi;
 import org.openstreetmap.josm.testutils.annotations.Projection;
@@ -99,3 +106,43 @@
         assertTrue(MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).isEmpty());
     }
+
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/24097">#24097</a>: Zoom to imagery layer
+     * This tests two things:
+     * <ul>
+     *     <li>Imagery layer zoom to action works properly</li>
+     *     <li>Imagery layer bounds is not zoomed to on layer add</li>
+     * </ul>
+     */
+    @Main
+    @Test
+    void testNonRegression24097() {
+        // First, add a new data layer
+        MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(),
+                "AddImageryLayerActionTest#testNonRegression24097", null));
+        // Now zoom to a random area
+        MainApplication.getMap().mapView.zoomTo(new Bounds(39.0665807, -108.5212326, 39.0793079, -108.4986591));
+        // Initialize the zoom actions
+        MainApplication.getMenu().initialize();
+        final Bounds startingBounds = MainApplication.getMap().mapView.getRealBounds();
+        ImageryInfo testInfo = new ImageryInfo("Test", "https://127.0.0.1/{zoom}/{x}/{y}.png", "tms", null, null, "Test");
+        testInfo.setBounds(new ImageryInfo.ImageryBounds("-0.001,-0.001,0.001,0.001", ","));
+        new AddImageryLayerAction(testInfo).actionPerformed(null);
+        GuiHelper.runInEDTAndWait(() -> { /* Sync GUI thread */ });
+        // There is a bit of zooming done during the load of the imagery
+        assertTrue(startingBounds.toBBox().bboxIsFunctionallyEqual(MainApplication.getMap().mapView.getRealBounds().toBBox(), 0.001),
+                "Adding an imagery layer should not zoom to the imagery layer bounds");
+        assertEquals(1, MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).size());
+        final TMSLayer tmsLayer = MainApplication.getLayerManager().getLayersOfType(TMSLayer.class).get(0);
+        final AutoScaleAction autoScaleAction = Arrays.stream(tmsLayer.getMenuEntries()).filter(AutoScaleAction.class::isInstance)
+                .map(AutoScaleAction.class::cast).findFirst().orElseThrow();
+        autoScaleAction.actionPerformed(null);
+        // We can't check the bbox here, since the mapView doesn't have any actual width/height.
+        // So we just check the center.
+        assertTrue(new Bounds(-0.001, -0.001, 0.001, 0.001)
+                .contains(ProjectionRegistry.getProjection().eastNorth2latlon(
+                        MainApplication.getMap().mapView.getCenter())),
+                "The action should have zoomed to the bbox for the imagery layer");
+    }
 }
