In your way, each image comes with a link to itself. And if you need to place an image with a link to the page of the site? Or a small image (icon) that does not need the img-responsive class?
There is another way to achieve the same goal. I use it in my projects. It is configured in several steps:
Step 1. Switchable image style
Surely you're using the stylescombo addon. Here he is:

The list of styles can (and should) be changed via config.stylesSet . Moreover, styles can be created not only inline or paragraph, but also unique to objects of different types. Including - for images. Here is the code we need for the image:
config.stylesSet = [ { name: 'Само-ссылка', type: 'widget', widget: 'image', attributes: { "class": 'img-with-link' } } ]
Now that you have selected an image in the stylescombo you can turn the Self-reference item on and off in stylescombo . This will add img-with-link to your image. And we will work with this class already in viewing mode.
Step 2. Unobtrusively adding self-reference
Your post is saved and we see it on the page. The image has an img-with-link class. Now we can unobtrusively load the js-script, find in it all the images with such a class, and do with them what we want. I do this:
$(document).ready(function() { var images = $('.img-with-link'); if (images.length) { images.each(function() { $(this).wrap("<a href='" + $(this).attr('src') + "' target='_blank'></a>"); }); } });
Each image I unobtrusively wrap a link to the image itself with target="_blank" so that the link opens in a new tab. If desired, you can also connect the js-lightbox or js-gallery here. Or add the img-responsive class to the image itself (although I recommend simply styling all the images inside the post just like the img-responsive class).
var imageSrcUrl = e.sender.originalElement.$.src;putconsole.log(e.sender.originalElement.$);and look at the browser console. Maybe among the properties of the displayed object will be seen the right. - Visman pm