image_hwstring

函数


image_hwstring ( $width, $height )
参数
  • (int|string)
    $width
    Image width in pixels.
    Required:
  • (int|string)
    $height
    Image height in pixels.
    Required:
返回值
  • (string) HTML attributes for width and, or height.
定义位置
  • wp-includes/media.php
    , line 155
引入
2.5.0
弃用

Retrieves width and height attributes using given width and height values.

Both attributes are required in the sense that both parameters must have a
value, but are optional in that if you set them to false or null, then they
will not be added to the returned string.

You can set the value using a string, but it will only take numeric values.
If you wish to put ‘px’ after the numbers, then it will be stripped out of
the return.

function image_hwstring( $width, $height ) {
	$out = '';
	if ( $width ) {
		$out .= 'width="' . (int) $width . '" ';
	}
	if ( $height ) {
		$out .= 'height="' . (int) $height . '" ';
	}
	return $out;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。