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

    I am building a website for an absolute un-geeky client who doesn’t and doesn’t want to know much about how to use a CMS.

    But he likes putting pictures up on his website and add captions to them to explain what they show. It’s only one to three pictures per page and they should be easy to position using the standard TinyMCE image popup.

    How would I start writing a snippet/component/plugin (?) that is able to look through the HTML of a page and add a caption with what was previously entered into the "Image description" or "Title" textfield?

    I would need something that hops in right before the content is sent off to the browser, parses the HTML to find all <img> tags. If the tag has a title or alt-tag in it, it uses said title in a <div> that is inserted after the image. Wrapped together in another div, I would then have the final - captioned - image.
    In case this is the way you propose I should walk, then how do I access the HTML before it is sent to the browser? Instead of using [[*content]] in the browser I could use a snippet that performs the necessary changes and then echoes the content. Correct?

    Or is this the wrong way of doing that? Is there already something with this functionality?

    Using MODx Revolution 2.0.0-pl rev7212.

    Any help is gladly appreciated smiley