I’m a youngster of the late ’80s and ’90s. Before all of us had cameras constructed into our cell phones—effectively, earlier than cell phones took off, actually—households would lug round Polaroid cameras to seize these particular moments. Even although I hated posing for awkward images with my siblings, I’m nonetheless nostalgic concerning the magic of movie from a bygone period.
Now, I’ve grown sufficiently old to see the return of bodily prints, sparked primarily by Fujifilm Instax. They are a minimum of in style within the journaling teams that I lurk round. I’ve but to shell out the cash for one in all Fujifilm’s mini cameras or smartphone printers, however I’m admittedly tempted. Perhaps it’s a fad, however I’m nonetheless pulled towards reliving that a part of my youth.
Regardless of whether or not I personal the bodily tools, I can all the time recreate Polaroid-style images on the internet. The WordPress block system makes it easy.
This Building with Blocks put up will cater primarily to theme authors. However, DIY customers also can strive their hand at it. The tutorial will stroll by the steps of making a Polaroid-style picture body as a customized block model.
For this tutorial, I used Twenty Twenty-Two and WordPress 6.0 Beta 2. It also needs to work with WordPress 5.9. For different themes, chances are you’ll want to regulate the colours.
Building the Block Style
Much of the enjoyable I’ve had with the block system has been creating customized kinds. They usually solely take a few strains of code to remodel blocks into one thing completely totally different. The Polaroid model is identical.
The first step is to make use of the register_block_style()
perform to register a customized model through your theme’s capabilities.php
:
add_action( 'init', 'tavern_register_block_styles' );
perform tavern_register_block_styles() {
register_block_style( 'core/picture', [
'name' => 'polaroid',
'label' => __( 'Polaroid', 'tavern' )
] );
}
Once registered, it would seem as a selectable model for the Image block within the editor. However, it nonetheless wants a customized design. For that, you solely want a little bit of CSS.
Add the next to your theme’s stylesheet or, ideally, register it through wp_enqueue_block_style()
:
.wp-block-image[class*=is-style-polaroid] {
box-sizing: border-box;
padding: 1rem;
background-color: #fff;
box-shadow: 0 4px 10px 0 rgba( 0, 0, 0, 0.3 ),
0 0 4rem rgba( 255, 255, 235, 0.5 ) inset;
}
.wp-block-image[class*=is-style-polaroid] figcaption {
margin-top: 1rem;
margin-bottom: 0;
}
That is actually it. Custom block kinds are such straightforward wins that I don’t perceive why extra theme authors will not be together with them. I had 70+ in my final theme undertaking, and I used to be holding again—OK, so I could have gone a little overboard.
If you wish to change the “age” of the photograph, you possibly can darken the inset
shadow within the above CSS. It is a delicate impact by default, however be at liberty to tinker with it.
Keen-eyed readers might have observed that I focused [class*=is-style-polaroid]
as an alternative of .is-style-polaroid
. There is a purpose for that. It cuts again on the code for added kinds constructed on the identical idea.
Bonus: Tilted Styles


A Polaroid-style body is a enjoyable impact, however we will take that one step extra and add variations for tilting photographs left or proper. Add the next to the prevailing tavern_register_block_styles()
perform created within the earlier part:
register_block_style( 'core/picture', [
'name' => 'polaroid-tilt-left',
'label' => __( 'Polaroid: Tilt Left', 'tavern' )
] );
register_block_style( 'core/picture', [
'name' => 'polaroid-tilt-right',
'label' => __( 'Polaroid: Tilt Right', 'tavern' )
] );
For every of the “tilt” kinds, you should use the remodel
CSS property together with the scale()
and rotate()
capabilities. I selected slight rotations of 2deg
and -2deg
, however you possibly can push that so far as you wish to get your most popular design.
.wp-block-image.is-style-polaroid-tilt-right {
remodel: scale( 0.99, 0.99 ) rotate( 2deg );
}
.wp-block-image.is-style-polaroid-tilt-left {
remodel: scale( 0.99, 0.99 ) rotate( -2deg );
}
One enjoyable impact is to take away the lean transformation when a customer hovers their mouse over the photographs. Use the next CSS for that:
.wp-block-image[class*=is-style-polaroid-tilt] {
transition: all 0.5s ease-in-out;
}
.wp-block-image[class*=is-style-polaroid-tilt]:hover {
remodel: scale( 1, 1 ) rotate( 0 );
}
Let me know within the feedback when you gave this block model a shot. If you actually wish to lean into the old-school Polaroid model, strive it with a customized handwriting font for the caption. Also, please share any customized image-related designs in case you have them.