diff --git a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
index 34b0cc0519..3ffab32b95 100644
--- a/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
+++ b/core/modules/ckeditor/js/plugins/drupalimage/plugin.js
@@ -193,6 +193,19 @@
           return;
         }
 
+        widget.on('data', function (event) {
+          // If a link has been set, move the caret from the previous location
+          // to select the image.
+          if (this.data.link) {
+            this.focus();
+            // Adding a link through setData('link') may affect the unlink
+            // button, so refresh the button state to enable/disable it.
+            if (editor.plugins.drupallink) {
+              editor.getCommand('drupalunlink').refresh(editor, editor.elementPath(this.element));
+            }
+          }
+        });
+
         widget.on('edit', function (event) {
           event.cancel();
           editor.execCommand('editdrupalimage', {
