Example CSS for the CKEditor Enhanced Image plugin

This is a community-contributed tutorial. This tutorial is over a year old and may not apply to your version of Concrete CMS.
Jul 17, 2017

http://ckeditor.com/addon/image2
Dashboard > System & Settings > Basics > Rich Text Editor > Enhanced Image

Enhanced Image Features:

  • allows for adding image captions (that will not be separated from the image when its location changes)
  • has all advantages of widgets, i.e. you can treat the image and its caption as one entity and select, delete, or move it in the editor content area as a whole
  • supports drag and drop for changing image position
  • provides image alignment CSS classes
  • includes hassle-free "click and drag" resizing

The Enhanced Image Plugin Compared to the Image Plugin:

The Enhanced Image plugin assigns classes for alignment and captions and adds the HTML for the captions. It is up to the individual or theme maker to write the CSS for these classes.

Alignment Classes

Left - the img tag is assigned the class content-editor-image-left.
Center - the picture tag is wrapped in a p tag with the class content-editor-image-center.
Right - the img tag is assigned the class content-editor-image-right.

Image Captions

When enabling image captions, the picture tag is wrapped in a figure tag with the class content-editor-image-captioned and an alignment class if an alignment has been selected. A figcaption tag is added after the picture tag with the default text of "Caption".

Example: captioned image with right alignment

<figure class="content-editor-image-captioned content-editor-image-right">
    <picture>
        <!--[if IE 9]><video style='display: none;'><![endif]-->
        <source srcset="/my_site/application/files/thumbnails/large/6015/0024/5193/happy_cupcake.jpg" media="(min-width: 900px)">
        <source srcset="/my_site/application/files/thumbnails/medium/6015/0024/5193/happy_cupcake.jpg" media="(min-width: 768px)">
        <source srcset="/my_site/application/files/thumbnails/small/6015/0024/5193/happy_cupcake.jpg">
        <!--[if IE 9]></video><![endif]--><img src="/my_site/application/files/thumbnails/small/6015/0024/5193/happy_cupcake.jpg" alt="happy_cupcake.jpg">
    </picture>
    <figcaption>Caption</figcaption>
</figure>

Example Alignment CSS

Left

.content-editor-image-left {
    float: left;
    margin: 10px 20px 10px 0;
}

Center

.content-editor-image-center img {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

Center (preserve styling when editing content)

.cke_widget_image .content-editor-image-center {
    margin: 10px 0;
    text-align: center;
}

Right

.content-editor-image-right {
    float: right;
    margin: 10px 0 10px 20px;
}

Example Alignment and Caption CSS

Standard

.content-editor-image-captioned {
    display: table;
    margin-bottom: 10px;
    margin-top: 10px;
}

.content-editor-image-captioned.content-editor-image-left {
    float: left;
    margin-left: 0;
    margin-right: 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left {
    float: left;
    margin: 10px 20px 10px 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left .content-editor-image-captioned {
    margin: 0;
}

div.content-editor-image-center .content-editor-image-captioned {
    margin: 20px auto;
}

.content-editor-image-captioned.content-editor-image-right {
    float: right;
    margin-left: 20px;
    margin-right: 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right {
    float: right;
    margin: 10px 0 10px 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right .content-editor-image-captioned {
    margin: 0;
}

.content-editor-image-captioned figcaption {
    caption-side: bottom;
    display: table-caption;
    padding-top: 10px;
    padding-bottom: 10px;
}

Standard with Background Color

.content-editor-image-captioned {
    display: table;
    margin-bottom: 10px;
    margin-top: 10px;
}

.content-editor-image-captioned.content-editor-image-left {
    float: left;
    margin-left: 0;
    margin-right: 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left {
    float: left;
    margin: 10px 20px 10px 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left .content-editor-image-captioned {
    margin: 0;
}

div.content-editor-image-center .content-editor-image-captioned {
    margin: 20px auto;
}

.content-editor-image-captioned.content-editor-image-right {
    float: right;
    margin-left: 20px;
    margin-right: 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right {
    float: right;
    margin: 10px 0 10px 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right .content-editor-image-captioned {
    margin: 0;
}

.content-editor-image-captioned figcaption {
    background: #f5f5f5;
    border: 1px solid lightgray;
    caption-side: bottom;
    display: table-caption;
    padding: 10px;
}

Overlay with Semi-transparent Background Color

.content-editor-image-captioned {
    display: inline-block;
    margin-bottom: 10px;
    margin-top: 10px;
    position: relative;
}

.content-editor-image-captioned.content-editor-image-left {
    float: left;
    margin-left: 0;
    margin-right: 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left {
    float: left;
    margin: 10px 20px 10px 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left .content-editor-image-captioned {
    margin: 0;
}

div.content-editor-image-center {
    text-align: center;
}

div.content-editor-image-center figcaption {
    text-align: left;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-center {
    text-align: center;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-center figcaption {
    text-align: left;
}

.content-editor-image-captioned.content-editor-image-right {
    float: right;
    margin-left: 20px;
    margin-right: 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right {
    float: right;
    margin: 10px 0 10px 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right .content-editor-image-captioned {
    margin: 0;
}

.content-editor-image-captioned figcaption {
    background: rgba(0, 0, 0, 0.5);
    bottom: 0;
    color: #fff;
    padding: 10px;
    position: absolute;
    width: 100%;
}

Hover Overlay with Semi-transparent Background Color

.content-editor-image-captioned {
    display: inline-block;
    margin-bottom: 10px;
    margin-top: 10px;
    position: relative;
}

.content-editor-image-captioned.content-editor-image-left {
    float: left;
    margin-left: 0;
    margin-right: 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left {
    float: left;
    margin: 10px 20px 10px 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-left .content-editor-image-captioned {
    margin: 0;
}

div.content-editor-image-center {
    text-align: center;
}

div.content-editor-image-center figcaption {
    text-align: left;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-center {
    text-align: center;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-center figcaption {
    text-align: left;
}

.content-editor-image-captioned.content-editor-image-right {
    float: right;
    margin-left: 20px;
    margin-right: 0;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right {
    float: right;
    margin: 10px 0 10px 20px;
}

/*preserve styling when editing content*/
.cke_widget_image.content-editor-image-right .content-editor-image-captioned {
    margin: 0;
}

.content-editor-image-captioned figcaption {
    background: rgba(0, 0, 0, 0.5);
    bottom: 0;
    color: #fff;
    display: block;
    opacity: 0;
    padding: 10px;
    position: absolute;
    transition: opacity 250ms;
    width: 100%;
}

.content-editor-image-captioned:hover figcaption {
    opacity: 1;
}

Tips:

  • There are situations where the text is not lined up horizontally with the top of the image. When that happens you can add vertical space by adding a br tag (Shift+Enter keys) or p tag (Enter key).
  • When using floated images with text on narrow screens, the available area for text is just big enough for a few words or less. This makes for a challenging reading experience. This can be prevented by adding a media query and removing the float on the image. The screen width for the media query will depend on the size of the text.
  • To make images responsive, add this CSS:

    div.ccm-page img {
        height: auto;
        max-width: 100%;
    }
    
Recent Tutorials
Using the Concrete Migration Tool Addon
Apr 27, 2023

How to use the Concrete CMS Migration Tool

How To Add Page Last Updated To Your Concrete CMS Pages
Mar 7, 2023

Concrete CMS has a page attribute you can add to a global area called "Page Date Modified." Here's how to add it

How To Exclude Subpages from Navigation
Dec 24, 2022

How to exclude subpages from navigation - useful for a news or blog link in your main navigation where you don't want all the subpages to appear in a drop down menu.

How Can I Change The Maximum Size Of Uploaded files
Dec 13, 2022

This tutorial explains how to update your php settings.

Updating Concrete Themes from Version 8 to Version 9
Nov 24, 2022

This tutorial covers commonly encountered issues when upgrading a Concrete CMS theme from version 8 to version 9

Transferring ownership of an add-on and a theme
Nov 15, 2022
By katzueno.

If you encounter a Concrete CMS add-on or theme that you love but not being maintained, you may want to ask the author to help or take over the add-on or theme. Here is the quick step-by-step guide of how to transfer the ownership.

Was this information useful?
Thank you for your feedback.