Archived topic
Default Centering for Image Blocks
11 replies · Started by Bruce on February 19, 2021
For every image we add (which is hundreds in a typical week) we need to manually adjust the alignment to 'centered'. Is there a way to have the default for an image block set to centered?
FYI - we're an older site that switched over to Generate Press last month. Very pleased and happy to see the Theme easily handle our 3+ million monthly pageviews.
Hi there,
thats impressive stats - glad to hear your enjoying the theme!
Any chance i can see an example post/page where there are images - just need to check the markup before offering some options.
Sure thing - thanks for your time.
https://thehockeywriters.com/kraken-expansion-draft-avoidance-list/
Hi Bruce,
You could try add this CSS, this should work for all single post pages.
.single .wp-block-image figure {
margin-left: auto;
margin-right: auto;
}
Let me know how it goes :)
Sorry Ying - that didn't seem to help. Added images at 575px remained left-justified.
Hi Bruce,
I just checked the page and all images are centered?
Ying's CSS should work.
Leo - our issue isn't how the posts look, it's the default image handling of wordpress that we would like to change. We have to manually center hundreds of images every week. I'm just looking for less work for my writers and editors by finding a way to change the default image block to being centered.
Not a big deal - the process only adds a few seconds - but we look to optimize were we can. thanks
I understand. And Ying's CSS should do exactly that.
If it isn't working for you, I'll need to see a page live with the issue on it to determine why it's not working.
Not to hijack someone else's thread, but I'm having the same issue. You can see in this post, I've manually centered each image until the last one. The CSS isn't centering it. https://somedayilllearn.com/bulk-food-storage/
Hi Chelsea,
It's much easier with a live site, so here you go:
.single .wp-block-image > *, .single .wp-block-image .wp-block-image {
text-align: center !important;
margin-left: auto !important;
margin-right: auto !important;
display: block !important;
float: none !important;
}
The CSS applies to all the single posts.
That did it! Thanks, Ying!
No problem :)