We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51910
    • 1 Posts
    Hello,

    I’m looking for a solution for how to enable my clients to insert images into their content (whereever they want them to) and include a caption under the image in a user friendly way.

    Is there a plugin for this? Or does anybody have a suggestion how to make this work in a user friendly way?

    Thank you!


      • 4172
      • 5,888 Posts
      IMO, let clients add images where ever they want, is never a good idea.
      Think alone about different screen-sizes.

      I would rather predefine some different content-blocks, for example image-right/text-left, image-left/text-right,fullwith-image,richtext-block, each with a caption-field for the image.

      Then let them add this content-blocks as they need them.
      This way, you have full control about the output-format of every block.

      Can be done with modmore's ContentBlocks or also possible with MIGX [ed. note: Bruno17 last edited this post 10 years, 5 months ago.]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 26681 MODX Staff
        • 123 Posts
        While I agree with Bruno, what you're asking about is possible with a Rich Text Editor. There are some free ones: TinyMCE, CKEditor, Tiny Rich Text, and a premium one Redactor. Most if not all have an image upload workflow that allows adding title or alt text attributes. You can target the content and display it with CSS or JS.
          [sepiariver.com] (https://sepiariver.com/)
          • 5430
          • 247 Posts
          Hello,

          I’m looking for a solution for how to enable my clients to insert images into their content (whereever they want them to) and include a caption under the image in a user friendly way.

          Is there a plugin for this? Or does anybody have a suggestion how to make this work in a user friendly way?

          Thank you!


            • 5430
            • 247 Posts
            Damn it. Sorry, tried to post from my phone and ended up simply duplicating your post. This is something I do on almost all my sites using a tiny bit of javascript. Depending on your WYSIWYG editor (I use Redactor, but they all offer some variation of this functionality), there's almost always a fairly simple way for users to insert an image and include copy within the alt="" attribute. This is usually called "title" or something like that within the WYSIWYG. Users can also usually add a class designation via the WYSIWYG. The resulting code would be something like the following:
            <img src="path/to/image.jpg" class="customClassName" alt="caption copy here"/>

            Your CSS can treat the image responsively via the class, and then a bit of javascript can check your document for this custom class, detect the alt attribute content, and rewrap the image inside a <div> tag with the caption copy displayed as text. Something like the following (using jQuery, events unchained for clarity):
            $('.customClassName').each(function(){
            		if ($(this).attr('alt').length > 0){
            			var thisclass = $(this).attr('class');
            			var thistext = $(this).attr('alt');
            			$(this).removeClass(thisclass);
            			$(this).wrap('<div class="'+thisclass+'"></div>')
            			$(this).parent().append('<p>'+thistext+'</p>');
            		}
            	})

            The result is a classed div with nested image an caption that's responsive via your CSS. Though I totally agree with Bruno17 on this, clients do tend to wreck sites this way, it's often completely unavoidable and I have to do it all the time.
              • 42562
              • 1,145 Posts
              With TinyMCE you can achieve any kind of browser-side manipulation.
              Draw an image and I will make you a 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.