jQuery(document).ready(function() {
    //**Insert image caption and containers for images in editor
    jQuery('div#content img.picture-align-left').each(function() {
        insertImageCaption(this, 'picture align-left');
    });
    jQuery('div#content img.picture-full-width').each(function() {
        insertImageCaption(this, 'picture');
    });
    function insertImageCaption(ctrl, cssclass) {
        img = jQuery(ctrl);
	if (img.parent().is('p')) {
            img.parent().before(img);
            html = jQuery.trim(img.parent().html().replace('&nbsp;',''));
             if (html.length == 0) {
                img.parent().remove();
            }
        }
        img.wrap('<div class="picture align-left"></div>');
        img.after('<div class="description"><p><small>' + img.attr('title') + '</small></p></div>');
        img.attr('title', img.attr('title').replace('&quot;', "'").replace('&quot;', "'"));
    }
});