• Resolved immaterial

    (@immaterial)


    Hello, I noticed that since I switched to TT3 all images that were centered before are now aligned to the left. Seems like the alignment is now just ignored by the system. What can I do to revert this? Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
    • Are you referring to images inside your posts pages?
    • Have you tried reactivating your previous theme?
    • Could you share a link to a page or post in your site where we could take a direct look?
    • Could you confirm what WordPress version you are using and if you are also using the Gutenberg plugin (and if so, what version)?

    Thank you!

    Thread Starter immaterial

    (@immaterial)

    Yes, I’m referring to posts (on Blog Home and Single post pages).

    In my previous theme (TT) it works, when reactivated in Live preview.

    I’m using WP 6.3 with Gutenberg plugin 16.5.0.

    Thank you for the additional details, @immaterial. I think I might have found what’s causing this. Where you by any chance using the Classic Editor when you wrote these posts in TT?.

    I found that when you insert an image in TT using the Classic Editor, the image will appear to be centred but if you check, you will notice it set as “No alignment”. As it turns out (and this is arguably a bug) TT displays “no aligment” images as centred.

    Screen Shot on 2023 08 28 at 16 19 37

    When you publish this (still using TT), it will appear as centred in the frontend too:

    Screen Shot on 2023 08 28 at 16 13 08

    The problem is that the image is not really centred, and when you switch themes, TT3 will align “No alignment” images to one side.

    To fix this, you can add the following custom CSS code:

    .single .entry-content > p > img.alignnone,
    .page .entry-content > p > img.alignnone {
      margin-left:auto;
      margin-right:auto;
      display:block;
    }

    The code above will center “No alignment” images inside your posts and pages. Please bear in mind that if you switch themes, you might run into this same issue again, so make sure you save this code somewhere for future reference.

    Thread Starter immaterial

    (@immaterial)

    Hi, thanks to you I now found the solution. The CSS-code you gave me didn’t solve the problem however.

    I am indeed using the Classic editor, but the images contain this, as an example:

    <img class="size-full wp-image-1111 aligncenter" etc.

    So now I modified your CSS in this way:

    img.aligncenter {
      margin-left:auto;
      margin-right:auto;
      display:block;
    }

    …and it worked. How come “aligncenter” doesn’t work automatically?

    I am glad you figured it out, and thank you for sharing your solution @immaterial. After some digging, I found a Trac issue and a GH issue where this is being discussed so, hopefully, it should be fixed soon. Thanks again!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Images not centered’ is closed to new replies.