wp_get_duotone_filter_svg

函数


wp_get_duotone_filter_svg ( $preset )
Access
Private
参数
  • (array)
    $preset
    Duotone preset value as seen in theme.json.
    Required:
返回值
  • (string) Duotone SVG filter.
定义位置
  • wp-includes/block-supports/duotone.php
    , line 399
引入
5.9.1
弃用

返回预设的duotone过滤器SVG字符串。

function wp_get_duotone_filter_svg( $preset ) {
	$filter_id = wp_get_duotone_filter_id( $preset );

	$duotone_values = array(
		'r' => array(),
		'g' => array(),
		'b' => array(),
		'a' => array(),
	);

	if ( ! isset( $preset['colors'] ) || ! is_array( $preset['colors'] ) ) {
		$preset['colors'] = array();
	}

	foreach ( $preset['colors'] as $color_str ) {
		$color = wp_tinycolor_string_to_rgb( $color_str );

		$duotone_values['r'][] = $color['r'] / 255;
		$duotone_values['g'][] = $color['g'] / 255;
		$duotone_values['b'][] = $color['b'] / 255;
		$duotone_values['a'][] = $color['a'];
	}

	ob_start();

	?>