Make WordPress Core

Opened 19 months ago

Closed 18 months ago

Last modified 2 months ago

#62243 closed defect (bug) (fixed)

Twenty Twenty: Latest post block there is no space between post-author/post-date and post content on the front-end.

Reported by: viralsampat's profile viralsampat Owned by: karmatosed's profile karmatosed
Milestone: 6.8 Priority: normal
Severity: minor Version:
Component: Bundled Theme Keywords: has-patch has-unit-tests
Focuses: css Cc:

Description

Hello Team,

I have checked "Latest Post" block and found that when we add post-author/post-date there is no space between post-author/post-date and post content on the front-end, But on the admin editor side it looks good, There is some space between post-author/post-date and post content.

For better understanding, Here I have attached its screenshots:

Thanks,

Attachments (7)

latest-post-block-editor.png (387.4 KB) - added by viralsampat 19 months ago.
Back-end
latest-post-block-editor.2.png (387.4 KB) - added by viralsampat 19 months ago.
Back-end:
latest-post-block-front-end.png (320.2 KB) - added by viralsampat 19 months ago.
Front-end:
62243.patch (555 bytes) - added by viralsampat 19 months ago.
I have checked above mentioned issue and I have resolved it and added patch. Also, I have attached screenshot after resolved this issue.
after-resolved-latest-post-block-editor.png (386.3 KB) - added by viralsampat 19 months ago.
After resolved issue Back-end:
after-resolved-latest-post-block-front-end.png (288.7 KB) - added by viralsampat 19 months ago.
After resolved issue front-end:
62243.1.patch (2.0 KB) - added by sabernhardt 18 months ago.
adds 1em top margin to a paragraph if it is the first element in the post content, within a Latest Posts block

Download all attachments as: .zip

Change History (30)

@viralsampat
19 months ago

I have checked above mentioned issue and I have resolved it and added patch. Also, I have attached screenshot after resolved this issue.

@viralsampat
19 months ago

After resolved issue Back-end:

@viralsampat
19 months ago

After resolved issue front-end:

#1 @sainathpoojary
18 months ago

Hey @viralsampat,

Thanks for raising this issue! I couldn’t reproduce it on my end.

Here’s what I tested:

  • Twenty Twenty theme on WordPress versions 6.7 to 6.4
  • Twenty Twenty theme on Local by Flywheel on WordPress 6.6

After checking the style.css file from core/latest-posts, I found this rule:

.wp-block-latest-posts__post-excerpt {
margin-top: 0.5em;
margin-bottom: 1em;
}

This CSS rule adds a top margin, which appears to be adding the gap.

You can view the relevant code here:

https://github.com/WordPress/gutenberg/blob/249c0cf495ed89df95e039572974bc948fa89731/packages/block-library/src/latest-posts/style.scss#L60C1-L63C2

Could you please provide more details or any additional steps needed to replicate the issue?

Thanks!

#2 @desrosj
18 months ago

  • Keywords reporter-feedback added; dev-feedback removed
  • Summary changed from Twenty Twenty Theme: Latest post block there is no space between post-author/post-date and post content on the front-end. to Twenty Twenty: Latest post block there is no space between post-author/post-date and post content on the front-end.

@viralsampat are you still able to reproduce this issue?

@sabernhardt
18 months ago

adds 1em top margin to a paragraph if it is the first element in the post content, within a Latest Posts block

#3 @sabernhardt
18 months ago

  • Keywords has-patch added; needs-patch reporter-feedback removed
  • Severity changed from normal to minor

The lack of space can occur when

  1. the Latest Posts block is set to show "Full post" and
  2. the first element/block in the post is a paragraph.

The excerpt option has a small margin from block styles (GB15722), but #47340 added a margin for the full post option in Twenty Nineteen and PR 153 set the same top margin for both options in Twenty Twenty-One.

In Twenty Twenty, paragraphs have zero top margin. In contrast, a heading as the first block can have a top margin of 3.5rem or more, and the Image block has a 4rem margin.

Patch notes:

  • If the selector targets the paragraph element, it needs to apply only when that paragraph is at the beginning of the post. 62243.1.patch uses .wp-block-latest-posts__post-full-content > p:first-child.
  • Targeting the .wp-block-latest-posts__post-full-content div is another option. It would give a minimum margin above the post content, and I did not notice that rule increasing the space when the first inner block has its own margin.
  • If this were the newest theme, I would suggest giving the :first-child a consistent margin regardless of the element. However, five years later, I would prefer to keep any changes minimal.
  • The .entry-content class (62243.patch) would apply styles only within page/post content, and the Latest Posts block is intended for the Widgets area(s).

#4 @abcd95
18 months ago

  • Keywords needs-testing removed

Test Report

Description

This report validates that the suggested patch works as expected.

Patch tested: 62243.1.patch

Environment

  • WordPress: 6.8-alpha-59274-src
  • PHP: 8.2.25
  • Server: nginx/1.27.2
  • Database: mysqli (Server: 8.0.40 / Client: mysqlnd 8.2.25)
  • Browser: Chrome 131.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty 2.8

Actual Results

✅ Issue resolved with the patch.

Supplemental Artifacts

Back-end: https://postimg.cc/xJn7Vv85
Front-end: https://postimg.cc/QFn13hMy

#5 @karmatosed
18 months ago

I am going to move this patch to testing; thanks.

#6 @karmatosed
18 months ago

  • Keywords commit added

In testing, I can confirm this is still an issue, but the patch uploaded by @sabernhardt resolves it. I am, therefore, going to move this to commit now. Thank you, everyone.

#7 @karmatosed
18 months ago

  • Owner set to karmatosed
  • Resolution set to fixed
  • Status changed from new to closed

In 59470:

Twenty-Twenty: Fixes space between post content on front.

The post author and post date did not have space between them and the post content. This brings in 1em of top margin. Of note is that this only is if the first element is a paragraph that the issue was caused.

Props abcd95, sabernhardt, desrosj, sainathpoojary, viralsampat.
Fixes #62243.

#8 @desrosj
17 months ago

  • Keywords commit removed
  • Milestone changed from Awaiting Review to 6.8

This ticket was mentioned in PR #10868 on WordPress/wordpress-develop by @adamsilverstein.


3 months ago
#9

  • Keywords has-unit-tests added

This PR contains the PHP backports for the client-side media processing feature, enabling the editor to perform client-side image resizing, thumbnail generation, and format conversion using WebAssembly.

## Preloaded Settings

The following site settings are now preloaded in both the post editor and site editor:

  • image_sizes - Available image size configurations
  • image_size_threshold - Big image size threshold (default 2560px)
  • image_output_formats - Output format mappings for image conversion
  • jpeg_interlaced - Whether to use progressive/interlaced JPEG encoding
  • png_interlaced - Whether to use interlaced PNG encoding
  • gif_interlaced - Whether to use interlaced GIF encoding

## REST API: Index Endpoint

Added media processing settings to the REST API index (/wp-json/wp/v2/):

  • image_sizes - All registered image sizes with dimensions and crop settings
  • image_size_threshold - Big image size threshold
  • image_output_formats - Format conversion mappings

## REST API: Attachments Endpoint

### New Fields

  • filename - Original attachment file name
  • filesize - File size in bytes
  • exif_orientation - EXIF orientation value (1-8) for client-side rotation handling

### New Parameters

  • generate_sub_sizes - When false, disables server-side sub-size generation and EXIF rotation
  • convert_format - When false, disables automatic image format conversion

### New Sideload Endpoint
Added /wp/v2/media/{id}/sideload endpoint for uploading sub-sized images to an existing attachment. Used by client-side media processing to upload generated image sizes without creating new attachments. Supports both images and PDFs.

### PDF Improvements
Improved missing_image_sizes field handling for PDFs, which use the fallback_intermediate_image_sizes filter instead of wp_get_missing_image_subsizes().

## Cross-Origin Isolation

Added COOP (Cross-Origin-Opener-Policy) and COEP (Cross-Origin-Embedder-Policy) headers in the block editor to enable SharedArrayBuffer for WebAssembly-based processing. Includes:

  • Output buffer to automatically add crossorigin="anonymous" attributes to external resources
  • Media templates updated with crossorigin attributes for audio, img, and video tags

## WASM Support

Added AddType directive for WebAssembly files to .htaccess rules, enabling serving .wasm files for client-side media processing libraries like wasm-vips.

## Tests

Updated REST API tests for the new attachment fields and sideload endpoint.

---

Gutenberg PRs:

Gutenberg tracking issue: https://github.com/WordPress/gutenberg/issues/75062

@adamsilverstein commented on PR #10868:


3 months ago
#10

Sorry for what may be an unsolicited early review, as the PR is still a draft.

No worries, happy to have your feedback. Indeed I started working on this pr before the Gutenberg work had merged to get ahead and be more prepared - so it may change a bit, but probably not much at this point.

@andrewserong commented on PR #10868:


3 months ago
#11

Just a quick comment: it looks like this accidentally removes the ca-bundle.crt file, so I assume needs a rebase?

@adamsilverstein commented on PR #10868:


3 months ago
#12

Just a quick comment: it looks like this accidentally removes the ca-bundle.crt file, so I assume needs a rebase?

oh, i thought i had added that file. will fix. Also figured out why this isn't working, fix incoming.

@adamsilverstein commented on PR #10868:


3 months ago
#13

Just a quick comment: it looks like this accidentally removes the ca-bundle.crt file, so I assume needs a rebase?

rebased and fixed.

@adamsilverstein commented on PR #10868:


3 months ago
#14

This is ready for additional testing, client side processing is now working as expected. In addition to smoke testing as is, it would be good to test with wp_is_client_side_media_processing_enabled set to false to verify server side processing kicks in as expected.

@adamsilverstein commented on PR #10868:


3 months ago
#15

@westonruter I believe I have addressed all outstanding feedback (except the output mapping one I will work on in a follow up). Can you give it another spin?

@mukesh27 commented on PR #10868:


3 months ago
#16

@adamsilverstein have you checked why unit tests are failed?

@adamsilverstein commented on PR #10868:


3 months ago
#17

@adamsilverstein[[Image(chrome-extension://hgomfjikakokcbkjlfgodhklifiplmpg/images/wp-logo.png)]] have you checked why unit tests are failed?

looking now...

@adamsilverstein commented on PR #10868:


3 months ago
#18

@adamsilverstein[[Image(chrome-extension://hgomfjikakokcbkjlfgodhklifiplmpg/images/wp-logo.png)]] have you checked why unit tests are failed?

looks like I just needed to update the wp-api fixtures which i did in 57c4f00 (by running the test_build_wp_api_client_fixtures test locally)

#19 @adamsilverstein
3 months ago

In 61703:

Editor: backport client side media PHP changes to core.

Bring over the changes required to implement client side media in core. This feature recently graduated from experiments and is ready for testing in beta.

Props adamsilverstein, westonruter, mamaduka, mukesh27, swissspidy, andrewserong, ellatrix, ramonjd.
Fixes #62243.

#20 @sabernhardt
3 months ago

(The client-side media PR 10868 and [61703] belong on #64597.)

#21 follow-up: @lopo
3 months ago

We are facing some problems with our worker on Yoast SEO with WP 7.0 beta or latest Gutenberg. It seems that the problem is related to the CORS headers changes introduced with this ticket. Is this an expected side-effect?

#22 in reply to: ↑ 21 @sabernhardt
3 months ago

problem is related to the CORS headers changes

@lopo For the client-side media ticket, please see #64597.

This ticket was mentioned in PR #11168 on WordPress/wordpress-develop by @adamsilverstein.


2 months ago
#23

## Summary

  • Adds a POST /wp/v2/media/{id}/finalize REST API endpoint to WP_REST_Attachments_Controller
  • The endpoint triggers the wp_generate_attachment_metadata filter with context 'update' after client-side media processing completes
  • Ensures server-side plugins (watermarking, CDN sync, custom sizes, etc.) can post-process attachments when client-side processing is active
  • Only registered when wp_is_client_side_media_processing_enabled() returns true

## Context

When client-side media processing handles image uploads (resizing, thumbnail generation, format conversion), server-side WordPress hooks like wp_generate_attachment_metadata are bypassed. This endpoint is called after all client-side operations (upload, thumbnail generation, sideloads) are complete, re-triggering the filter so plugins continue to work.

### Hook usage example

add_filter( 'wp_generate_attachment_metadata', function( $metadata, $attachment_id, $context ) {
  // $context is 'update' when called from the finalize endpoint.
  if ( 'update' === $context ) {
    // Add watermark, sync to CDN, generate custom sizes, etc.
    my_plugin_process_attachment( $attachment_id, $metadata );
  }
  return $metadata;
}, 10, 3 );

## Changes

File Change
class-wp-rest-attachments-controller.php Add finalize route registration, finalize_item_permissions_check(), and finalize_item() methods
rest-attachments-controller.php (tests) Add tests for finalize endpoint (success, auth required, invalid ID)
rest-schema-setup.php Add finalize route to expected routes list
wp-api-generated.js Add finalize route to API fixtures

## Test plan

  • [ ] Verify finalize endpoint returns 200 with valid attachment
  • [ ] Verify wp_generate_attachment_metadata filter fires with context 'update'
  • [ ] Verify 401 when not authenticated
  • [ ] Verify 404 for invalid attachment ID
  • [ ] Run full REST API test suite

## Related

---
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with Claude Code

Note: See TracTickets for help on using tickets.