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

[Block Themes] By default, images inserted from the Classic editor flow offscreen #38384

Closed
kjellr opened this issue Jan 31, 2022 · 1 comment · Fixed by #38399
Closed

[Block Themes] By default, images inserted from the Classic editor flow offscreen #38384

kjellr opened this issue Jan 31, 2022 · 1 comment · Fixed by #38399
Assignees
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@kjellr
Copy link
Contributor

kjellr commented Jan 31, 2022

By default, Images that are inserted by the Classic editor can easily flow offscreen. Traditional themes tend to have CSS that prevents this, but block themes don't by default.

Screen Shot 2022-01-31 at 12 39 49 PM

To reproduce:

  1. Activate a block theme (emptytheme or Twenty Twenty-Two for example)
  2. Activate the Classic Editor plugin.
  3. In a new post, add an image. Choose the "Large" (or Full) size.
  4. Preview the post in the front end, note that the image is not bound by any max-width rules.
@kjellr kjellr added [Type] Bug An existing feature does not function as intended [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Jan 31, 2022
@jasmussen
Copy link
Contributor

Great ticket, thank you, I've managed to reproduce, and here's some test content that doesn't require you to install the classic editor:

<!-- wp:paragraph -->
<p>Non clasic:</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":525,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="http://local-wordpress.local/wp-content/uploads/2021/12/flight-path-on-gray-a.jpeg" alt="" class="wp-image-525"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Classic:</p>
<!-- /wp:paragraph -->

<p><img class="alignnone wp-image-525 size-full" src="http://local-wordpress.local/wp-content/uploads/2021/12/flight-path-on-gray-a.jpeg" alt="" width="2100" height="994"></p>

This is the result:
before

It's a tricky one, because I'm not quite sure if we should do anything. Images inserted using the classic editor are not "blocks", and there's an argument to be made that because of this, the intent of the image isn't entirely clear, and therefore the domain of the theme to style. And yes, themes commonly provide something like this to handle that:

img {
	max-width: 100%;
	height: auto;
}

Right now we provide this for Image blocks, like so:

.wp-block-image {
	margin: 0 0 1em 0;

	img {
		height: auto;
		max-width: 100%;
		vertical-align: bottom;
	}
}

That logic scopes the rule very precisely, to only images in the image block. Writing a similar rule to scope a similar rule to a non-block image is not trivial.

The only other idea I have, for which there will be a PR below this comment in a moment, is to remove the responsiveness rule from the Image block, and move it to common.scss. That should target both objects with low specificity, so we avoid complex rules. But it does add more boilerplate CSS, which is not always wanted. Hopefully the PR is a great way to test this idea, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants