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

Image Block: MediaPlaceholder / MediaUpload component doesn't addapt to small sizes #54867

Closed
fabiankaegy opened this issue Sep 27, 2023 · 5 comments · Fixed by #64320
Closed
Labels
[Block] Image Affects the Image Block [Feature] Component System WordPress component system Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.

Comments

@fabiankaegy
Copy link
Member

fabiankaegy commented Sep 27, 2023

Description

When an image block for example is used with a fixed height and width in a Pattern where it doesn't have an image selected yet, the image will render the MediaPlaceholder

But since an image can be really small the MediaPlaceholder should ideally adapt to the small size and display an alternate layout.

You can see the overflowing issue in the screencast I attached below

Step-by-step reproduction instructions

  1. Insert this block pattern for example:
Code sample
<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"var:preset|spacing|60","bottom":"var:preset|spacing|60","left":"var:preset|spacing|60","right":"var:preset|spacing|60"}}},"backgroundColor":"contrast","textColor":"base","layout":{"type":"constrained","contentSize":""}} -->
<div class="wp-block-group alignfull has-base-color has-contrast-background-color has-text-color has-background" style="padding-top:var(--wp--preset--spacing--60);padding-right:var(--wp--preset--spacing--60);padding-bottom:var(--wp--preset--spacing--60);padding-left:var(--wp--preset--spacing--60)"><!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"align":"center","style":{"typography":{"lineHeight":"1.2"}},"textColor":"base","fontSize":"x-large","fontFamily":"heading"} -->
<p class="has-text-align-center has-base-color has-text-color has-heading-font-family has-x-large-font-size" style="line-height:1.2"><em>“Études has saved us thousands of hours of work and has unlocked insights we never thought possible.”</em></p>
<!-- /wp:paragraph -->

<!-- wp:spacer {"height":"var:preset|spacing|10"} -->
<div style="height:var(--wp--preset--spacing--10)" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:group {"style":{"spacing":{"blockGap":"0"}},"layout":{"type":"flex","orientation":"vertical","justifyContent":"center","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:image {"align":"center","width":"60px","aspectRatio":"1","scale":"cover","sizeSlug":"thumbnail","linkDestination":"none","style":{"border":{"radius":"100px"}}} -->
<figure class="wp-block-image aligncenter size-thumbnail is-resized has-custom-border"><img alt="" style="border-radius:100px;aspect-ratio:1;object-fit:cover;width:60px"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"center","style":{"spacing":{"margin":{"top":"var:preset|spacing|10","bottom":"0"}}}} -->
<p class="has-text-align-center" style="margin-top:var(--wp--preset--spacing--10);margin-bottom:0">Annie Steiner</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"center","style":{"typography":{"fontStyle":"normal","fontWeight":"300"}},"textColor":"contrast-3","fontSize":"small"} -->
<p class="has-text-align-center has-contrast-3-color has-text-color has-small-font-size" style="font-style:normal;font-weight:300">CEO, Greenprint</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->
  1. Try to fill in the image in the pattern via the Media placeholder

Screenshots, screen recording, code snippet

CleanShot.2023-09-27.at.14.39.53.mp4

Related issue: #64288.

Suggestion

Apply a minimal version of Placeholder that is shown when the block is narrow. Already in place are CSS classes is-medium and is-small, which can be used to change the appearance based on context.

Mockup:

image placeholders

Details:

  • "Add image" is added to the block toolbar when it's in a placeholder state. This button serves as a dropdown, making it similar in behavior to how Cover, and Site Logo works.
  • In the smallest <60px state, the white placeholder material isn't shown at all, even if it's shown on select in the larger states.

Issue updated Aug 7. Figma.

@jordesign jordesign added [Type] Enhancement A suggestion for improvement. [Block] Image Affects the Image Block [Feature] Component System WordPress component system labels Sep 27, 2023
@jordesign jordesign changed the title MediaPlaceholder / MediaUpload component doesn't addapt to small sizes Image Block: MediaPlaceholder / MediaUpload component doesn't addapt to small sizes Sep 27, 2023
@richtabor
Copy link
Member

I wonder if it's be more useful as a button to open the Media Library when it's under a certain height/width.

@annezazu
Copy link
Contributor

Just ran into this today with 6.5.3 and I agree that this is rough. Adding this to the Polish board as it would be good to iterate here.

@annezazu annezazu added this to Polish May 28, 2024
@annezazu annezazu moved this to Needs design in Polish May 28, 2024
@jasmussen jasmussen moved this to Next in Design priorities Jun 17, 2024
@jasmussen jasmussen moved this from Next to Now in Design priorities Aug 6, 2024
@jasmussen jasmussen moved this from Now to Needs Dev in Design priorities Aug 7, 2024
@jasmussen jasmussen moved this from Needs design to Needs development in Polish Aug 7, 2024
@jasmussen jasmussen added the Needs Dev Ready for, and needs developer efforts label Aug 7, 2024
@jasmussen
Copy link
Contributor

Based on conversation, feedback, and design iterations on a related issue (#64288), I went ahead and updated this issue with a fresh design and shuffled the labels around.

@jasmussen
Copy link
Contributor

Actually based on work in #64320 (kudos @vipul0425), one thing we can do is add only a single text-item to the block toolbar in its placeholder state "Choose image", rather than have separate items, since the dropdown it would open is needed regardless for extensibility. CC: @WordPress/gutenberg-design for input.

@jasmussen
Copy link
Contributor

Updated to reflect the work in progress in #64320.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Feature] Component System WordPress component system Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.
Projects
Status: Done
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants