The Before and After block A piece of a page, such as a paragraph, a picture or a button. In WordPress you build a page by putting blocks one after another. puts two pictures on top of each other, with a divider between them. A visitor moves the divider to compare the two. It is good for a repair, a makeover or a photo edit. See it working on the Before and After page.
Add a before and after
Add the Before and After block.
Press Add the before picture and pick a picture.
Press Add the after picture and pick the other one. Two pictures of the same shape work best.
Type your own words over Before and After on the picture, or leave them. To remove a label, delete its text.
Type a caption under the picture if you want one. Bold, links and other formats work there.
Once both pictures are in, Before picture and After picture in the panel have Replace and Remove. Swap pictures exchanges the two.
The settings
The Before and After panel in the Settings tab lists, after the pictures, in this order:
- Image size: Medium, Medium large, Large or Full size, Large to start. It is the file a visitor loads. A larger one is sharper and slower.
- Shape: Same as the before picture to start, or 16:9, 3:2, 4:3 or 1:1. See below.
- Direction: Side by side to start, or Top and bottom.
- Start position: 0 to 100, 50 to start. It says how much of the before picture shows at first, in percent.
- Moves on: Drag to start, Mouse over the picture or Page scroll. See below.
- Show the move once: off to start. The divider moves a little and comes back when a visitor reaches it, so they see that it can be moved. It leaves the panel with Page scroll.
- Labels: Always, On hover or Never. On a device with no hover, On hover shows them always.
- Dim on hover: off to start. Both pictures go darker while the mouse is on them.
- Show the handle: on to start. The handle is the line and the round grip. With it off, they still show when a visitor moves to the block with the keyboard.
Two pictures of different shapes
With the Shape setting at its start, the block takes the before picture’s shape. If the after picture has another shape, it is cropped to fit, and the panel warns you: “These two pictures have different shapes, so the after picture is cropped to fit the before picture. Pick a Shape, or use two pictures of the same shape.” The warning leaves when you pick a shape, or when the shapes match.
How the divider moves
- Drag: a press anywhere on the picture moves the divider there, and it follows the mouse. It stays where you let go.
- Mouse over the picture: the divider follows the mouse with no press.
- Page scroll: the picture goes from before to after as the block passes up the screen. It stops following when the visitor moves the divider.
A press and the keyboard work with all three. The keyboard takes one Tab stop. The arrow keys move the divider 1 step, Page Up and Page Down move it 10, and Home and End go to the ends. With Top and bottom, the Up key moves the divider up. The whole picture shows a ring while the keyboard is on it.
On a touch screen, a finger sliding sideways moves the divider, and a tap moves it there. A slide up scrolls the page and leaves the divider alone.
How it looks
To style it, open the block in Cairnstone → Blocks. Pick Labels, Handle or Caption beside Style: above the block, then set the colours in the Styles tab. The grip’s text colour also colours the line. The block’s corners come from Styles too, 12 pixels to start.
Good to know
- Visitors who ask their device for less motion get no small move. The divider stays at its start position, and they can still move it. Page scroll stops following too.
- With no script, both pictures show whole, one above the other, with their labels, and there is no divider.
- With one picture, the block shows a plain picture with no divider. With no picture, it draws nothing.
- A screen reader A program that reads the screen aloud, for people who cannot see it well. They move around the page with the keyboard and hear what is there. reads each picture’s description from the media library, its label and the caption, so write a description for both.
- With the Tab key, a screen reader says what the divider does and how much of each picture shows, such as “From the camera 50 percent, Edited 50 percent”. Each key press says the new values. With Top and bottom, it does not say that the divider moves up and down. Show the move once says nothing to a screen reader.
- On a right-to-left page, the before picture starts on the right.
- At 0 and 100 percent, the round grip stands half outside the picture. It can still be moved.
Next, read Show one big picture at a time.