Skip to content

6.0 Upgrade Does Not Keep Image Alignment  #41365

Closed

Description

@ObviousInvestor

Description

Pages compiled with latest 6.0 version aligns images left on update if they are set to align center. Align right works, but it does not respect images set to align center.

When I update a page in 6.0 (even without changing anything), all images on that page that have alignment set to "Center" align left.

This is quite serious as it stops me from being able to edit a page without messing everything up.

Step-by-step reproduction instructions

Just update any page with 6.0 editor and problem occurs

You can see in the attached image, the blue "Numbers updated" image and the yellow meme are both images set to center alignment.

Screenshots, screen recording, code snippet

Screenshot - 26_05_2022 , 09_04_37

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. justintadlock commented on May 26, 2022

    @justintadlock
    Contributor

    I was unable to reproduce this. Images aligned center in the editor and on the front-end for me with and without Gutenberg 13.3 active on WP 6.0.

    @ObviousInvestor - Can you test this with the Twenty Twenty-Two theme active? If still not working, can you copy/paste the block code here?

  2. ObviousInvestor commented on May 26, 2022

    @ObviousInvestor
    Author
  3. ashleyleia commented on May 27, 2022

    @ashleyleia

    I'm having this issue with image alignment, but it's only happening with Astra theme (and I don't have Gutenberg active).

    @ObviousInvestor - There's a thread related to this on the Astra theme support forum here: https://wordpress.org/support/topic/wordpress-6-0-image-alignment-not-working-2/

  4. ObviousInvestor commented on May 27, 2022

    @ObviousInvestor
    Author
  5. added
    [Type] BugAn existing feature does not function as intended
    Needs TestingNeeds further testing to be confirmed.
    on May 27, 2022
  6. gmcneel commented on May 28, 2022

    @gmcneel

    I am having this issue too. On WP Version 6.0 and Colibri WP theme. Looks fine in editor view, but live view does not work. Here is an example.

    https://renewalvaporblasting.com/heavy-renewal-for-a-heavy-lifter/

  7. perherngren commented on May 30, 2022

    @perherngren

    I also have this issue. On WP Version 6.0 and Astra theme free. In the editor it says align center. But the actual image aligns left both back end and front end.

  8. Benji-create commented on Jun 2, 2022

    @Benji-create

    I have the same Problem. Does somebody have a fix?

  9. ashleyleia commented on Jun 2, 2022

    @ashleyleia

    I have the same Problem. Does somebody have a fix?

    On the Astra support forum thread on this, they say: "Yes, we are aware of this issue and have planned to include the fix in the next release. Please consider reaching out to us through our Support Portal so we can provide you with the dev version that contains the fix."

    As a workaround in the meantime, since pretty much all of my images are supposed to be centered, I've added this custom CSS in the WP Customizer, which overrides the theme and centers every image block across my whole site:
    .wp-block-image {margin: auto !important;}

  10. bengs commented on Jun 2, 2022

    @bengs

    In Wordpress 6.0 the core image block's output has changed to apply the .wp-block-image class to the same <figure> element as the .alignright and .alignleft classes are applied. The core CSS still only targets child elements though so the alignment styles are not applied.
    Before Wordpress 6.0:

    <div class="wp-block-image">
        <figure class="alignright">

    In Wordpress 6.0 the output changes to this (if you've upgraded, it will happen next time you resave a page/post):

    <figure class="wp-block-image alignright">

    Adding some extra css to your theme to target both scenarios should fix it for people encountering this issue in the meantime eg:

    .wp-block-image.alignleft,
    .wp-block-image .alignleft {
            /*rtl:ignore*/
            float: left;
            /*rtl:ignore*/
            margin-left: 0;
            margin-right: 1em;
            margin-top: 0.5em;
            margin-bottom: 0.5em;
    }
    .wp-block-image.alignright,
    .wp-block-image .alignright {
            /*rtl:ignore*/
            float: right;
            /*rtl:ignore*/
            margin-right: 0;
            margin-left: 1em;
            margin-top: 0.5em;
            margin-bottom: 0.5em;
    }
  11. t-hamano commented on Jun 4, 2022

    @t-hamano
    Contributor

    Hi @ObviousInvestor,

    I have addressed this issue in a previous PR #39594.

    However, as this comment suggests, the layout of blocks placed at the root level of content looks to be an issue that should be addressed by the theme.

    This is not an issue that is specific to the "image block" or "center alignment" though. As you can see on the "layout support" dev note. These themes are still required to define the layout for their "root" level. In the case of astra I guess it's .entry-content.

    So, I would like to close this issue as this is not a Gutenberg issue and a fix is planned according to the Astra forum topic.

    If you have any problems or questions, please do not hesitate to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] ImageAffects the Image Block[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions