# Image Alignment

**URL:** https://meta.discourse.org/t/image-alignment/15408
**Category:** Feature
**Created:** [May 7, 2014, 5:56pm UTC](https://meta.discourse.org/t/image-alignment/15408 "2014-05-07T17:56:14Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![itlo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itlo/32/3742_2.png) [@itlo](https://meta.discourse.org/u/itlo)
#### Post date: [May 7, 2014, 5:56pm UTC](https://meta.discourse.org/t/image-alignment/15408/1 "2014-05-07T17:56:14Z")

</div>

Any plan to add a feature for Image Alignment and Wrapping Text Around Images? More formmating options for photos (uploaded or linked) would be very useful. Cheers.

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [June 8, 2018, 8:00pm UTC](https://meta.discourse.org/t/image-alignment/15408/18 "2018-06-08T20:00:17Z")

</div>

This question comes up all the time in my community. We’d love to be able to include a small image or two in our posts without interrupting the flow of text.

Here’s a typical example..

 ![47%20PM](https://global.discourse-cdn.com/meta/original/3X/0/5/05546c9c3591981cdf29276581395e6695e26db2.png)

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [June 9, 2018, 5:38am UTC](https://meta.discourse.org/t/image-alignment/15408/19 "2018-06-09T05:38:22Z")

</div>

You don’t need a plugin to whitelist classes anymore, you can just use `data-theme-*` attributes directly in your post’s markup.

You’d do something like

```HTML
<div data-theme-image="left">
  <img src="https://example.com/example.jpg" >
</div>

```

and then in your site customizations you’d have add corresponding CSS

```CSS
[data-theme-image="left"] {
    float: left;
    img {
      margin: 1.3em 1em 0 0;
    }
}

```

 ![38%20AM](https://global.discourse-cdn.com/meta/original/3X/f/a/face8fbfbe35fc7a69d4342057e6212c19955d4e.png)

Might be a good case for a simple theme component.

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [June 9, 2018, 8:36am UTC](https://meta.discourse.org/t/image-alignment/15408/20 "2018-06-09T08:36:27Z")

</div>

> [@awesomerobot](#):
>
> img[data-theme-image=“left”] { float: left; margin-right: 1em; }

I had to look this one up. In case anyone else is wondering how this works, here you go:

> **[Attribute selectors - CSS | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Attribute_selectors)**
>
> The CSS attribute selector matches elements based on the element having a given attribute explicitly set, with options for defining an attribute value or substring value match.

> [@awesomerobot](#):
>
> Might be a good case for a simple theme component.

So let’s see if I understand how this would work. One way would be to add a toolbar button that would add a `div` with the `data-theme-image` attribute, just like here (where a different attribute is added):

> <https://github.com/discourse/Discourse-Tiles-image-gallery/blob/ae11e1b19d72eb71194cb02cf833fb8a0eeb18fa/common/head_tag.html#L41-L59>

Right?

Now, if I think that adding a toolbar button each for aligning images, say, left right centre (or even adding a toolbar button at all) and I instead want to manually add a `[floatl]` tag which would then be converted into html, then I would need a plugin, right?

---

<div class="post-metadata">

### Author: ![Steven](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven/32/187890_2.png) [@Steven](https://meta.discourse.org/u/Steven)
#### Post date: [June 10, 2018, 12:06am UTC](https://meta.discourse.org/t/image-alignment/15408/23 "2018-06-10T00:06:08Z")

</div>

I’ve done a plugin with some formatting options, center, align right, float element, color. You can activate/deactivate any option

> [@Formatting toolbar](https://meta.discourse.org/t/formatting-toolbar/40649):
>
> Add some formatting options to your discourse posts : center a text or an image, align to the right, justify, colors, underline, etc. It’s easy to use and it will provide some options to embellish your posts.

It’s using bbcodes tho, it may not be as clean as other options

---

<div class="post-metadata">

### Author: ![oreillyc](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/oreillyc/32/212955_2.png) [@oreillyc](https://meta.discourse.org/u/oreillyc)
#### Post date: [March 14, 2021, 3:41pm UTC](https://meta.discourse.org/t/image-alignment/15408/31 "2021-03-14T15:41:52Z")

</div>

The formatting toolbar [did the trick](https://forums.sociocracyforall.org/t/exponential-organizations-book-discussion/28) ez-pz for me! Thanks @Steven

> [@Formatting toolbar](https://meta.discourse.org/t/formatting-toolbar/40649):
>
> Add some formatting options to your discourse posts : center a text or an image, align to the right, justify, colors, underline, etc. It’s easy to use and it will provide some options to embellish your posts.

> **Float right bbcode**
> 
> We have a floatl bbcode (and button) that allows you to add a content on the left of your text (like the [image in this example](https://raw.githubusercontent.com/iunctis/discourse-formatting-toolbar/master/formatting.png)). There is also a `[floatr][/floatr]` bbcode, that adds a content on the right. The bbcode has been created but I didn’t add a button, it doesn’t feel necessary.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [April 5, 2021, 8:04pm UTC](https://meta.discourse.org/t/image-alignment/15408/33 "2021-04-05T20:04:01Z")

</div>

I went ahead and cleaned up this topic a bit so that the most relevant information is highlighted.

Below is a summary of the current options for allowing image alignment in posts, ordered by ease of installation/use:

- [MD Composer extras](https://meta.discourse.org/t/md-composer-extras/118912) (theme component)
- [Formatting toolbar](https://meta.discourse.org/t/formatting-toolbar/40649) (plugin)
- Build your own solution: [Image Alignment - #19 by awesomerobot](https://meta.discourse.org/t/image-alignment/15408/19) and if you want to add a toolbar button, there is an example in [Image Alignment - #20 by tophee](https://meta.discourse.org/t/image-alignment/15408/20)

---

<div class="post-metadata">

### Author: ![krauss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/krauss/32/221613_2.png) [@krauss](https://meta.discourse.org/u/krauss)
#### Post date: [May 22, 2021, 2:08pm UTC](https://meta.discourse.org/t/image-alignment/15408/34 "2021-05-22T14:08:25Z")

</div>

Some news here? **I am an user** , I **only need to post a content with image-align-right**.

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [May 22, 2021, 9:45pm UTC](https://meta.discourse.org/t/image-alignment/15408/35 "2021-05-22T21:45:40Z")

</div>

See [What is the code for centering an uploaded image? - #14 by jomaxro](https://meta.discourse.org/t/what-is-the-code-for-centering-an-uploaded-image/77446/14). Instead of `center`, use `right`.

---

<div class="post-metadata">

### Author: ![mattdm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mattdm/32/216484_2.png) [@mattdm](https://meta.discourse.org/u/mattdm)
#### Post date: [November 2, 2021, 3:12pm UTC](https://meta.discourse.org/t/image-alignment/15408/36 "2021-11-02T15:12:45Z")

</div>

> [@jomaxro](#):
>
> See [What is the code for centering an uploaded image? - #14 by jomaxro](https://meta.discourse.org/t/what-is-the-code-for-centering-an-uploaded-image/77446/14). Instead of `center` , use `right` .

That can right-align the image, but won’t float it, right? That is, no wrapped text, which is _probably_ what’s wanted?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [November 2, 2021, 6:16pm UTC](https://meta.discourse.org/t/image-alignment/15408/37 "2021-11-02T18:16:06Z")

</div>

> [@mattdm](#):
>
> That can right-align the image, but won’t float it, right?

That is correct. The topic I linked to wanted to center an image, and that’s all it does. If you also want `float` you’ll need to follow [Kris’s suggestion](https://meta.discourse.org/t/image-alignment/15408/19) (which requires that action be taken by an admin to get it set up) or install a plugin like the Formatting toolbar.

---

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [November 2, 2021, 7:31pm UTC](https://meta.discourse.org/t/image-alignment/15408/38 "2021-11-02T19:31:08Z")

</div>

Just noting that floating is also supported with the [MD Composer extras](https://meta.discourse.org/t/md-composer-extras/118912) component. It will add a button to the composer that might make things a little smoother.
