We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53985
    • 13 Posts
    Hi,
    I am looking to modify the html code of the TinyMCE editor for inserting images.

    By default, the code of the image tag with the TinyMCE editor is of the type:
    <img src="assets/images/image.jpg" alt="test" title="test" width="280" height="158" />


    I would like the html code written by the TinyMCE editor to be:
    <amp-img class="respons-loader" src="assets/images/image.jpg" alt="test" title="test" width="280" height="158" /> 
       <img class="responsive" src="assets/images/image.jpg" alt="test" title="test">
    </amp-img>


    Comparing we see that it is necessary:
    1) Add "amp-" before "img":
    so instead of having the opening of the image tag "<img" we would get "<amp-img"
    2) Add the class I named: "respons-loader":
    so we would get
    <amp-img class ="respons-loader" src ="assets/images/image.jpg" alt ="test" width="280" height="158"/>

    3) And finally add the following two lines of code:
    <img class="responsive" src="assets/images/image.jpg" alt ="test" title ="test">
    </Amp-img>


    Regards
      • 42562
      • 1,145 Posts
      Yes this is very possible with a custom plugin.
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
        • 53985
        • 13 Posts
        I do not know how to create a plugin for now. But I want to try to create my first plugin ...
          • 42562
          • 1,145 Posts
          I'll whip something up and share the fiddle when I get some time
            TinymceWrapper: Complete back/frontend content solution.
            Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
            5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
            • 53985
            • 13 Posts
            it's very nice thank you Donshakespeare!
              • 53985
              • 13 Posts
              Hi,
              Waiting to make a plugin I would like to make the change in manual.
              Can you guide me please?