Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Add caption to image in redactor?

I can't figure out how to do it easily.

Comments

  • It will let you put alt text in by clicking on the image then clicking the Edit that shows up on click.

    It doesn't really do <figcaption> style captions though, although you can make that work with a few lines of jQuery.

    Let's see...

    <script>
    $(function () {
        // Convert all img tags inside the main #content div into figures
        $('#content img').each (function () {
            var $this = $(this),
                alt = $this.attr ('alt');
    
            if (alt !== undefined) {
                $this.wrap ('<figure></figure>');
                $this.after ('<figcaption>' + alt + '</figcaption>');
            }
        });
    });
    </script>
    

    I did something based on the above for a site we built recently :)

  • That's cool. Did you add it to the front end of the site or was it part of the redactor interface? It would be great if the redactor modal dialog included a checkbox "use alt tag as caption."

  • I just included it in the template. That would be a cool feature though.

    I wonder if I could modify the "Images: Editable Photo" dynamic object to have a caption option? It will already read the link from the file's Link property, so it could take the Description property and make it a figcaption too.

  • I haven't really used the Editable Photo dynamic object before. I'll check it out.

Sign In or Register to comment.