Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images are centered in editor and aligned left in preview #31011

Closed
TheMinimalistNinja opened this issue Apr 20, 2021 · 6 comments
Closed

Images are centered in editor and aligned left in preview #31011

TheMinimalistNinja opened this issue Apr 20, 2021 · 6 comments
Labels
[Block] Image Affects the Image Block [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed

Comments

@TheMinimalistNinja
Copy link

Description

When I preview a post with WordPress images that are aligned center with the Gutenberg tool shows up as being aligned left in the preview.

Step-by-step reproduction instructions

Picture should align-center when align-center is selected in the editor

Actual behaviour

Picture aligns left in preview

This is the CSS rule which is causing the issue, which is located in https://www.theminimalistninja.com/wp-includes/css/dist/block-library/style.min.css:

.wp-block-image .aligncenter > figcaption, .wp-block-image .alignleft > figcaption, .wp-block-image .alignright > figcaption {
display: table-caption;
caption-side: bottom;
}

As a quick fix, I have added the below to my site via https://support.pipdig.co/articles/wordpress-how-to-add-or-edit-css/

.wp-block-image .aligncenter > figcaption {
display: block !important;
}

After removing this, the image appears in the center - https://pip.click/16189096817.png

WordPress information

  • WordPress version: 5.7.1
  • Gutenberg version: Unsure where to find this info
  • Are all plugins except Gutenberg deactivated? No
  • Are you using a default theme (e.g. Twenty Twenty-One)? No

Device information

  • Device: Desktop
  • Operating system: macOS catalina
  • Browser: Firefox
    chfcmkjjcihhpcgj
@paaljoachim paaljoachim added the [Block] Image Affects the Image Block label Apr 21, 2021
@hsingyuc
Copy link
Contributor

@TheMinimalistNinja I couldn't reproduce the issue, may I know which theme you are using?

@steve6375
Copy link

steve6375 commented May 18, 2021

I use current latest Astra theme and current latest WP
Steps to reproduce:

  1. In any page, add a new Image block
  2. Click on Media and select any image
  3. Type in a caption in the editor - notice that the caption is shown centred in the editor, but the image is left-aligned
  4. Now click on Preview - both image and caption are left aligned
  5. Page can be saved - editor always show caption as centred until you actually change its alignment to left by using the caption alignment control.

@TheRadicalDreamer
Copy link

I was able to repro here:
#33349

@paaljoachim
Copy link
Contributor

Hey @TheMinimalistNinja

The problem is known, but no solution has been added yet.
Here is an older issue:
#17162 (comment)

I assume we can close your issue, as it is a duplicate of the one I linked to.

@paaljoachim paaljoachim added the [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed label Oct 8, 2021
@paaljoachim
Copy link
Contributor

Check out the PR here: #35787

An easy way to test the PR is following this method: https://make.wordpress.org/design/2021/03/03/testing-a-gutenberg-pull-request-pr/

@annezazu
Copy link
Contributor

Closing this out as a duplicate based on the above :) Let me know if this needs to be reopened though or if I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed
Projects
None yet
Development

No branches or pull requests

6 participants