render_block_core_image

函数


render_block_core_image ( $attributes, $content )
参数
  • (array)
    $attributes
    The block attributes.
    Required:
  • (string)
    $content
    The block content.
    Required:
返回值
  • (string) Returns the block content with the data-id attribute added.
定义位置
  • wp-includes/blocks/image.php
    , line 16
引入
弃用

Renders the `core/image` block on the server,
adding a data-id attribute to the element if core/gallery has added on pre-render.

function render_block_core_image( $attributes, $content ) {
	if ( isset( $attributes['data-id'] ) ) {
		// Add the data-id="$id" attribute to the img element
		// to provide backwards compatibility for the Gallery Block,
		// which now wraps Image Blocks within innerBlocks.
		// The data-id attribute is added in a core/gallery `render_block_data` hook.
		$data_id_attribute = 'data-id="' . esc_attr( $attributes['data-id'] ) . '"';
		if ( ! str_contains( $content, $data_id_attribute ) ) {
			$content = str_replace( '
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。