Responsive images code on upload in tinymce for resources

Hello there!

I dont know if there is an easy solution for this, but Im asking anyway:

Do you know if there is a way, to automatically place responsive code (like an image+ template) when a client loads up some image in a resource?


your random kangeroo

Maybe instead of mixing text and images in TinyMCE you can use a block editor like ContentBlocks to separate them. Then it is easy to change the template of the images.

1 Like

I’m not saying this is efficient but what I usually do in a case like this is create a series of image TVs i.e. *Image01, *Image02, *Image03 etc and then create a chunk for each with relevant template and including the image tv. Then get the client used to placing the chunk where they want the image. I’ve found they soon get used to it if you keep the chunk names simple i.e. [[$Image01]], [[$Image02]] etc. It’s not going to work well for any more than 10 or so images but generally fine.

1 Like

maybe another solution

1 Like

Another alternative I use outside of modx is I have a lot of different type of users so I try to find solutions outside of multiple point uploads.

1 Like

I am usualy using javascript to accomplish that…

var contentImages = $('#content').find('img');
    if (contentImages.length) {
        $.each(contentImages, function (index, item) {
                    .wrap('<a href="' + $(item).prop('src') + '" class="fancybox img-hover-v1"></a>');
1 Like

You can also add to the TinyMCE configuration, something like this
image_class_list: [
{title: ‘img-responsive’, value: ‘img-responsive’},
Exactly how to do that depends on which package you have installed.

1 Like