• Hi, I’m currently using the Ollie theme and I want to keep images centered but left justify the captions under them. (Same for YouTube captions.)

    I’ve searched all over for how to do this and have tried various CSS snippets in the (now hidden) additional CSS code box. Apparently there may have once been a setting in the Image Block for this pre 6.31 but I don’t see it.

    Any advice on the best practices way to change this would be appreciated.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • If you add this code snippet to your “Additional CSS” box for the Image block, it will align your captions left:

    & .wp-element-caption {
        text-align: left;
    }

    As far as I know, there’s never been a setting to control caption alignment in the user interface.

    Thread Starter strasburgva

    (@strasburgva)

    Thanks. But I’d have to do that each time I add an image?

    Thread Starter strasburgva

    (@strasburgva)

    I tried this code on an Image Block and it didn’t take or I did it wrong:

    https://youtu.be/Pn1MjjdB_cY?si=C8w-QWDqdiaGcJEB

    To add styles for the Image block, you need to do it via the Appearance > Editor > Styles interface.

    Here’s a guide on adding per-block styles: https://www.ads-software.com/documentation/article/styles-overview/#per-block-css

    This will change the CSS for all Image blocks on the site.

    Thread Starter strasburgva

    (@strasburgva)

    Thank you so much for that. That’s a whole section I wasn’t aware of I will dig into!

    I put the code you suggested into the additional CSS for the Image Block and it has correctly left-justified captions under all images with one exception: Post Featured Image.

    I am currently using FSM Custom Featured Image Caption plugin to add captions to the featured image. They were still center-aligned. Adding the code to the Additional CSS for Post Featured Image did not cause the text to left-justify. I assume because the plugin was adding that caption as WordPress chooses to not caption the Featured Image for reasons which I do not understand.

    So I have:
    – disabled the FSM Custom Featured Image Caption plugin
    – edited my Single Post template to remove the Post Featured Image block

    Now I have manually added an Image Block to the top of the posts (which may or may not be the same as the Featured Image).

    This causes me to have to add that going forward but gives me control on whether to have the featured image on top or not or another image and whatever I put there will obey the additional CSS for Image Block.

    Does this seem like a logical way to handle this?

    Personally, I prefer for to not have the featured image on single posts, so that would be how I’d do it. This just gives more control over the content output to me.

    Thread Starter strasburgva

    (@strasburgva)

    Okay cool. Thank you again very much! Full site editing and the block editing features are exciting but it can be overwhelming as I learn!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to left justify image captions’ is closed to new replies.