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

Cover block: Change dimRatio to 50 if media added and dimRatio is set to 100 #35789

Merged
merged 2 commits into from Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/cover/edit.js
Expand Up @@ -333,7 +333,7 @@ function CoverEdit( {
gradientValue,
setGradient,
} = __experimentalUseGradient();
const onSelectMedia = attributesFromMedia( setAttributes );
const onSelectMedia = attributesFromMedia( setAttributes, dimRatio );
const isUploadingMedia = isTemporaryMedia( id, url );

const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/cover/shared.js
Expand Up @@ -32,7 +32,7 @@ export function dimRatioToClass( ratio ) {
: 'has-background-dim-' + 10 * Math.round( ratio / 10 );
}

export function attributesFromMedia( setAttributes ) {
export function attributesFromMedia( setAttributes, dimRatio ) {
return ( media ) => {
if ( ! media || ! media.url ) {
setAttributes( { url: undefined, id: undefined } );
Expand Down Expand Up @@ -65,6 +65,7 @@ export function attributesFromMedia( setAttributes ) {
}

setAttributes( {
dimRatio: dimRatio === 100 ? 50 : dimRatio,
url: media.url,
id: media.id,
alt: media?.alt,
Expand Down