-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add more data about the image as block props in the image block #11973
Closed
+736
−148
Closed
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
4eb7ee5
Add fileWidth, fileHeight, userSet, editWidth props
azaozz fe99150
Merge branch 'master' into fix/image-block-add-props
azaozz 1105451
Fix upscaling
azaozz 1c5b8a0
Fix param/prop names
azaozz dc8133c
Merge branch 'master' into fix/image-block-add-props
azaozz 03444d7
Better filter name, allow valueless attributes
azaozz fc7c8a6
Merge branch 'master' into fix/image-block-add-props
aduth 1aa5b35
Compat: Resolve PHP lint errors
aduth 2a9fba9
Compat: Correct closing img tag
aduth 04706dd
Compat: Allow optional space after img tag name
aduth 08473d8
Compat: PHPDoc formatting and arrangement style
aduth 32d5c8c
Blocks: Use Math.round for image rounding
aduth cf50aec
Blocks: Add deprecation for attribute-sourced URL, alt
aduth e4cfea3
Blocks: Use hard-coded content width for block width
aduth 4c49a8d
Blocks: Limit editWith assignment to insert, resize
aduth f9da97f
Blocks: Rename Image userSet to userSetDimensions
aduth 8cef6ac
Blocks: Remove redundant userSetDimensions normalization
aduth 84d6866
Blocks: Document constrainImageDimensions as ported from PHP
aduth db48c26
Blocks: Avoid mutative, unused Array#map result
aduth b2bc0e7
Block: Avoid overloading Image block updateImageURL
aduth f69ec35
Blocks: Fix Image accidental inline tab character
aduth 009eceb
Compat: Avoid assumption of ID as non-last attribute of image
aduth bf9d58c
Compat: Document image block RegEx as temporary solution
aduth 51e6c96
Blocks: Pick url, alt in raw transform from image node
aduth 174bee0
Framework: Regenerate fixtures
aduth c26abe2
Blocks: Update image fixtures per url, alt as comment attributes
aduth 579cf12
Compat: Align PHPDoc return
aduth 9563082
Compat: Add PHPDoc since tag
aduth 6efdb5c
Merge branch 'master' into fix/image-block-add-props
aduth a0a6dd9
Blocks: Remove outdated comment about floated images width accuracy
aduth 8e73feb
Compat: Remove any attributes containing invalid characters
aduth 8535d73
Blocks: Reintegrate media attributes pick to setAttributes spread
aduth 4d2d959
Blocks: Set Image fileWidth, fileHeight only if both present
aduth 19dad07
Compat: Use spec standard for valid attribute characters
aduth 87130e4
Editor: Compute expected block width by DOM compute
aduth e2f8007
Compat: Always write img attribute value, even empty
aduth bf67408
Blocks: Avoid multiple calls to setAttributes in resetWidthHeight
aduth d8d7d6e
Update the 25-50-75-100% buttons
azaozz e3a99c7
Check only for valid HTML 5.0 attribute names
azaozz 44c7c68
Update handling of "wide" and "full" alignment for the front-end
azaozz 652ac92
Merge master
azaozz 078a75b
Update `const getBlockWidth` to get the width from `div.editor-block-…
azaozz 4be9bee
Fix typo in https://github.com/WordPress/gutenberg/pull/11973/commits…
azaozz 4b0425f
Fix missing space to make wpcs happy
azaozz 648811f
Update `gutenberg_render_block_core_image()`
azaozz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Blocks: Limit editWith assignment to insert, resize
- Loading branch information
commit 4c49a8dba1f5a87a467764822d7c2a356cbe975d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no need here for two calls to
setAttributes()
- we can collapse them into one in a couple of different ways. my favorite is withObject.assign()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. The purpose here is to make it as easy to read and understand as possible. After going through babel and minification, the code that actually runs in production will be completely different.
(I actually "have a beef" with the way a lot of the code is written. All the redundant indentation, nested lambda functions (no names = poor context), "clever" conditionals, almost no inline comments... There seem to be quite a few cases where the code becomes more readable after running it through babel and minification, then "unminifying" it. But lets look at that after 5.0 is out.) :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Noting that the supplied example doesn't use
Object.assign
and wouldn't work as written)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! 😆 (fixed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main thing for me here would be to avoid multiple calls to
setAttributes
, as it will incur a render for each (unnecessary impact on performance). This will remain true after transpilation and minification.I pushed bf67408 which I think is a reasonable compromise to preserve a similar readability.