Skip to content

Image galleries - #523

Merged
javan merged 76 commits into
masterfrom
image-galleries
Sep 13, 2018
Merged

javan merged 76 commits into
masterfrom
image-galleries

Conversation

@javan

@javan javan commented Jul 19, 2018 •

Copy link
Copy Markdown
Contributor

This pull request adds support for displaying groups of images in a grid, AKA image galleries. It works by automatically grouping adjacent image attachments into blocks, and styling the block's attachment elements to form a grid. The layout is 100% CSS-based so it can easily be customized or adjusted for different viewport sizes using media queries. Out of the box, Trix supports two and three column grids controlled by just a few styles in trix.css:

.attachment-gallery {
display: flex;
flex-wrap: wrap;
position: relative;
margin: 0;
padding: 0;
.attachment {
flex: 1 0 33%;
padding: 0 0.5em;
max-width: 33%;
}
&.attachment-gallery--2,
&.attachment-gallery--4 {
.attachment {
flex-basis: 50%;
max-width: 50%;
}
}
}

→

→

→

Additional changes

  1. Attachment toolbars now include file metadata, and their markup and has been revised to align more closely with <trix-toolbar>'s.
    screen shot 2018-07-25 at 9 43 48 am

  2. Text formatting can no longer be applied to attachments because, in part, the resulting HTML would break image gallery layouts. It also had weird/inconsistent results before and could easily happen accidentally (dropping images into bold text, for example).
    disabled-attributes

  3. Attachments with href attributes now render <a>s inside their <figure>s.

    <!-- BEFORE -->
    <a href="…">
      <figure>
        <img src="…">
        <figcaption>…</figcaption>
      </figure>
    </a>
    
    <!-- AFTER -->
    <figure>
      <a href="…">
        <img src="…">
        <figcaption>…</figcaption>
      </a>
    </figure>

javan added 30 commits May 9, 2018 14:22
Extract new Document and Text methods from Composition logic
@javan javan added the WIP label Jul 19, 2018
@leandromatos

Copy link
Copy Markdown

Amazing! I look forward to the acceptance of this pull request. 👏🏻

Fixes caption editing in Safari and restores the normal selection to caption input elements in all browsers.
@randohinn

Copy link
Copy Markdown

Seems like the styles are not included by default? Had to add manually to https://www.npmjs.com/package/trix

@javan

javan commented Oct 30, 2018

Copy link
Copy Markdown
Contributor Author

@randohinn, see Styling Formatted Content:

We encourage you to use these styles as a starting point by copying them into your application’s CSS with a different class name.

@mrancys

mrancys commented Dec 10, 2019

Copy link
Copy Markdown

Will image linking functionality be restored in some future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants