-
Notifications
You must be signed in to change notification settings - Fork 4.7k
AspectRatioDropdown: List theme aspect ratios as decimal values #74729
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @stian-overasen! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Retrying this bugfix after my last PR was ignored. This problem is very much still an issue and should be fixed. |
|
This patch is currently fixing the issue in both unminified and minified #!/usr/bin/env bash
#
# WordPress Core Patches
# This script applies necessary patches to WordPress core files after composer updates
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
WP_INCLUDES="$PROJECT_ROOT/public/wp/wp-includes"
echo "Applying WordPress core patches..."
# Patch 1: Fix aspect ratio bug in block-editor.js
# Bug: themeRatios needs .map(presetRatioAsNumber) transformation
# Affects: WordPress core block editor aspect ratio selector
echo " → Patching block-editor.js aspect ratio bug..."
# Patch unminified version
UNMINIFIED="$WP_INCLUDES/js/dist/block-editor.js"
if [ -f "$UNMINIFIED" ] && grep -q 'aspectRatios: themeRatios$' "$UNMINIFIED"; then
# Create backup
cp "$UNMINIFIED" "$UNMINIFIED.bak"
# Apply patch - replace the line that ends with themeRatios
sed -i.tmp 's/aspectRatios: themeRatios$/aspectRatios: themeRatios.map(presetRatioAsNumber)/g' "$UNMINIFIED"
rm -f "$UNMINIFIED.tmp"
echo " ✓ Fixed block-editor.js (unminified)"
elif [ ! -f "$UNMINIFIED" ]; then
echo " ⚠ File not found: block-editor.js"
else
echo " ℹ Already patched: block-editor.js"
fi
# Patch minified version
MINIFIED="$WP_INCLUDES/js/dist/block-editor.min.js"
if [ -f "$MINIFIED" ] && grep -q 'aspectRatios:s[,}]' "$MINIFIED"; then
# Create backup
cp "$MINIFIED" "$MINIFIED.bak"
# Apply patch - replace aspectRatios:s} or aspectRatios:s,
sed -i.tmp 's/aspectRatios:s\([,}]\)/aspectRatios:s.map(RP)\1/g' "$MINIFIED"
rm -f "$MINIFIED.tmp"
echo " ✓ Fixed block-editor.min.js (minified)"
elif [ ! -f "$MINIFIED" ]; then
echo " ⚠ File not found: block-editor.min.js"
else
echo " ℹ Already patched: block-editor.min.js"
fi
echo ""
echo "✓ WordPress core patches applied successfully"
echo ""
echo "Patches applied:"
echo " 1. Block editor aspect ratio transformation bug"
echo ""
|
What?
This PR fixes the bug with custom theme aspect ratios (Issue #66077) in the image cropper tool by mapping the theme ratios as decimal values in the
AspectRatioDropdowncomponent (Same as is already done for the default aspect ratios)Why?
Fixes #66077
How?
Map theme aspect ratios as calculated decimal values (16:9 = 1.777) the same way that is already done for default aspect ratios.
Testing Instructions
theme.json. Example below.Example of custom theme aspect ratio in theme.json:
Screencast before fix:
before.mp4
Screencast after fix:
after.mp4