Media · Gutenberg
Before/After Slider block for WordPress
Compare two images with a draggable slider handle.
Get Blockenberg
Free Gutenberg block in Blockenberg. The inspector controls and front-end behavior on this page come from this block’s source, not a shared stub.
What it actually does
Compare two images with a draggable slider handle.
Inspector panels on this block: Images, Slider, Labels, Handle, Frame. Those titles come from index.js, not from a shared template.
Behavior controls: “Orientation” options: Horizontal, Vertical; “Aspect ratio” options: Auto, 1:1, 4:3, 3:2, 16:9; “Label position” options: Top, Bottom; “Handle style” options: Circle, Square.
Where to find it
Gutenberg inserter → Media → search “Before/After Slider” (block name `blockenberg/before-after` in block.json). Style it in the sidebar after insert.
How to use Before/After Slider block for WordPress
- Install Blockenberg. Install from WordPress.org and activate the plugin.
- Insert the block. Edit a page, click +, search for “Before/After Slider”, insert it. Category: Media.
- Configure inspector controls that exist on this block. Open Images. Set “Orientation”, “Start position (%)”, “Minimum height (px)”, “Aspect ratio”.
- Check the published page. The view script reads HTML data attributes: data-orientation, data-pos. The block editor preview may not run the same view script.
Inspector controls from this block’s code
| Control | What the code does |
|---|---|
| Orientation | Select control; the chosen value is saved on the block. Options: Horizontal; Vertical. block.json default: horizontal. Saved as `orientation`. |
| Start position (%) | Numeric range control in the inspector. Range 0–100. block.json default: 50. Saved as `startPosition`. |
| Minimum height (px) | Numeric range control in the inspector. Range 120–900. block.json default: 260. Saved as `minHeight`. |
| Aspect ratio | Select control; the chosen value is saved on the block. Options: Auto; 1:1; 4:3; 3:2; 16:9; 21:9. block.json default: auto. Saved as `aspect`. |
| Show labels | On/off toggle in the inspector. On by default. Saved as `showLabels`. |
| Label position | Select control; the chosen value is saved on the block. Options: Top; Bottom. block.json default: top. Saved as `labelPosition`. |
| Before label | Text field in the inspector. block.json default: Before. Saved as `beforeLabel`. |
| After label | Text field in the inspector. block.json default: After. Saved as `afterLabel`. |
| Label radius | Numeric range control in the inspector. Range 0–30. block.json default: 6. Saved as `labelRadius`. |
| Handle style | Select control; the chosen value is saved on the block. Options: Circle; Square. block.json default: circle. Saved as `handleStyle`. |
| Handle size | Numeric range control in the inspector. Range 28–80. block.json default: 44. Saved as `handleSize`. |
| Handle icon size | Numeric range control in the inspector. Range 10–34. block.json default: 18. Saved as `handleIconSize`. |
| Divider line width | Numeric range control in the inspector. Range 1–8. block.json default: 2. Saved as `lineWidth`. |
| Animate handle | On/off toggle in the inspector. Off by default. Saved as `handleHoverAnim`. |
| Animation | Select control; the chosen value is saved on the block. Options: Pulse; Wiggle; Bounce; Glow. block.json default: pulse. Saved as `handleHoverAnimType`. |
| Animation duration (ms) | Numeric range control in the inspector. Range 150–2000. block.json default: 650. Saved as `handleHoverAnimDuration`. |
| Enlarge icon area on hover | On/off toggle in the inspector. On by default. Saved as `handleHoverScale`. |
| Hover scale | Numeric range control in the inspector. Range 1–1.25. block.json default: 1.08. Saved as `handleHoverScaleAmount`. |
| Border radius | Numeric range control in the inspector. Range 0–40. block.json default: 12. Saved as `borderRadius`. |
| Frame — Shadow | On/off toggle in the inspector. Off by default. Saved as `shadow`. |
| Label | Shared Blockenberg typography popover (family, size, weight, spacing). Saved as `labelTypo`. |
What the front-end script actually does
- The view script reads HTML data attributes: data-orientation, data-pos.
When this is the right block
- Compare two images with a draggable slider handle — that is the job of Before/After Slider, not a generic content block.
- Use it when you need the editor control labeled “Orientation”, which exists on this block’s inspector.
- It matches pages about before after, comparison, slider.
- Inserter grouping: video, animation, and rich media sections.
Notes from the implementation
viewScript: this folder’s frontend.js is enqueued on the front end for this block.
FAQ
How do I add the Before/After Slider block in WordPress?
Install Blockenberg from WordPress.org, edit a page in the block editor, click +, and search for “Before/After Slider”. It sits under Media. After insert, open Images and set “Orientation”, “Start position (%)”, “Minimum height (px)”, “Aspect ratio”.
What makes Before/After Slider different from other Blockenberg blocks?
Compare two images with a draggable slider handle. Inspector labels on this block include “Orientation”, “Start position (%)”, “Minimum height (px)”, “Aspect ratio”.
Is the Before/After Slider Gutenberg block free?
Yes. Before/After Slider ships inside Blockenberg. Get the plugin from WordPress.org — no paid add-on is required for this block.
Can I style Before/After Slider to match my theme?
Yes. Blockenberg’s shared typography and color panels apply here, plus any block-specific style controls listed on this page (panels: Images, Slider, Labels, Handle).
Related media blocks
Before / After Grid
A grid of interactive before/after image comparison sliders — show multiple transformations, makeovers, or design iterations in one layout.
Image Slider
A responsive image carousel with captions, autoplay, arrows, dots and touch support.
Image Cards
A responsive grid of rich cards with images, category tag, title, description and CTA. Perfect for blog previews, portfolio, services or team showcases.
Image Collage
Creative overlapping image composition with up to 5 images, custom rotations, positions, frames and a floating overlay card. Perfect for hero and about sections.
Image Gallery
Responsive image gallery with grid/masonry layouts, lightbox, and hover effects.
Image Overlap Text
Creative editorial layout where a large image bleeds into an adjacent text column with decorative accents.
Get Blockenberg
Install Blockenberg from WordPress.org, then insert Before/After Slider from the Gutenberg inserter.