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

Set width and height for Block Editor images #1900

Closed
wants to merge 7 commits into from

Conversation

t-wright
Copy link
Contributor

@t-wright t-wright commented Dec 7, 2020

Description

Fixes #1391 by adding the correct width and height attributes to images added to post content using the block editor. Needs proper testing and consideration. cc @brandon-m-skinner: as mentioned in BB8-6850.

Checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally (or has an appropriate fallback).
  • This change works and has been tested on a Go sandbox.
  • This change has relevant unit tests (if applicable).
  • This change has relevant documentation additions / updates (if applicable).

Steps to Test

Outline the steps to test and verify the PR here.

  1. Enable the block editor with add_filter( 'use_block_editor_for_post', '__return_true' );
  2. Create a new post
  3. Add an image block, choosing an image from the media library that has dimensions wider than a large image
  4. In the block inspector, choose a display size other than Full Size
  5. Publish the post and observe that the width and height attributes on the <img> element are those of the full size image.
  6. Apply this PR
  7. Reload the browser and observe that the dimensions reflect those of the size chosen in the block attributes.

@rinatkhaziev
Copy link
Contributor

@t-wright Looks good, but I didn't get to test it. Do you mind fixing the lint issues, as pointed out here?

@rinatkhaziev
Copy link
Contributor

@t-wright one follow-up request - could you please leave comments inside those functions signifying which parts exactly were modified?

@brandon-m-skinner brandon-m-skinner marked this pull request as ready for review February 1, 2021 21:54
@brandon-m-skinner brandon-m-skinner requested a review from a team as a code owner February 1, 2021 21:54
@mikeyarce
Copy link
Member

I was testing a few potential solutions and then noticed this has been fixed in Core for 5.7 here: https://core.trac.wordpress.org/ticket/51865

Closing this PR as the core fix addresses this issue.

@mikeyarce mikeyarce closed this Mar 1, 2021
@pauarge pauarge deleted the fix/block-editor-image-size branch July 23, 2021 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter sizes value for intermediate images
6 participants