Skip to content

Commit

Permalink
Add a comment and remove the toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Dec 7, 2023
1 parent a2ebf5c commit a161d4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 0 additions & 10 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,6 @@ export default function PostFeaturedImageEdit( {
/>
</>
) }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Use first image from post' ) }
onChange={ ( value ) =>
setAttributes( {
useFirstImageFromPost: value,
} )
}
checked={ useFirstImageFromPost }
/>
</PanelBody>
</InspectorControls>
</>
Expand Down
13 changes: 13 additions & 0 deletions packages/block-library/src/post-featured-image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ function render_block_core_post_featured_image( $attributes, $content, $block )
$content_post = get_post( $post_ID );
$content = $content_post->post_content;
$processor = new WP_HTML_Tag_Processor( $content );
/*
* Transfer the image tag from the post into a new text snippet.
* Because the HTML API doesn't currently expose a way to extract
* HTML substrings this is necessary as a workaround. Of note, this
* is different than directly extracting the IMG tag:
* - If there are duplicate attributes in the source there will only be one in the output.
* - If there are single-quoted or unquoted attributes they will be double-quoted in the output.
* - If there are named character references in the attribute values they may be replaced with their direct code points. E.g. `&hellip;` becomes `…`.
* In the future there will likely be a mechanism to copy snippets of HTML from
* one document into another, via the HTML Processor's `get_outer_html()` or
* equivalent. When that happens it would be appropriate to replace this custom
* code with that canonical code.
*/
if ( $processor->next_tag( 'img' ) ) {
$tag_html = new WP_HTML_Tag_Processor( '<img>' );
$tag_html->next_tag();
Expand Down

0 comments on commit a161d4d

Please sign in to comment.