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

fixed Empty space when an empty image block #39952

Closed

Conversation

poojabhimani12
Copy link
Contributor

Fixed #39612

What?

Remove Empty space on the front end when an empty image block is added.

Why?

It will add an

unnecessary empty image tag on front end layout

How?

check condition if an image is set then only it will display the image tag

Testing Instructions

  1. Open the Post page

  2. Insert Image block but do not add any image

  3. Front end you can check there is no empty figure tag

Screenshots or screencast

image-block-backend

image-block-frontend

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Mar 31, 2022
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @poojabhimani12! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@amustaque97 amustaque97 added the [Block] Gallery Affects the Gallery Block - used to display groups of images label Apr 2, 2022
@Soean
Copy link
Member

Soean commented Jun 2, 2022

Maybe we can add the check earlier at line 28:

if ( ! url ) {
   return null;
}

@poojabhimani12
Copy link
Contributor Author

Yes, I have updated code as per your comment

@@ -27,6 +27,9 @@ export default function save( { attributes } ) {
} = attributes;

const newRel = isEmpty( rel ) ? undefined : rel;
if ( ! url ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( ! url ) {
if ( ! url ) {

There are two spaces, we need to remove one. We also can move it above the line with const newRel = ....

@Soean
Copy link
Member

Soean commented Jun 2, 2022

The tests are failing, we also need to adjust the snapshots: https://github.com/WordPress/gutenberg/pull/39952/checks

@ramonjd
Copy link
Member

ramonjd commented Aug 30, 2022

I'm not sure this work for empty images inside a gallery block:

Screen Shot 2022-08-30 at 3 34 15 pm

I followed the test instructions for #39612

@t-hamano
Copy link
Contributor

t-hamano commented Dec 8, 2023

It seems like this issue has already been resolved, so I'd like to close it. You can check the details of the test in this comment.

Therefore, I'm closing this PR.

@poojabhimani12 Thank you for your contribution 😊

@t-hamano t-hamano closed this Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gallery block: Empty space on front-end when an empty image block is added
5 participants