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_timezone_stringimage_resizeget_image_tagimage_add_captionadd_image_size
引入
2.5.0
棄用
-

image_hwstring: 這個函式用來建立一個字串,代表一個影象的寬度和高度。

使用給定的寬度和高度值檢索寬度和高度屬性。

這兩個屬性都是必需的,因為這兩個引數都必須有一個值,但也是可選的,因為如果你把它們設定為false或null,那麼它們將不會被新增到返回的字串中。

你可以用一個字串來設定值,但它只接受數字值。如果你希望在數字後面加上’px’,那麼它將被從返回值中剝離出來。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function image_hwstring( $width, $height ) {
$out = '';
if ( $width ) {
$out .= 'width="' . (int) $width . '" ';
}
if ( $height ) {
$out .= 'height="' . (int) $height . '" ';
}
return $out;
}
function image_hwstring( $width, $height ) { $out = ''; if ( $width ) { $out .= 'width="' . (int) $width . '" '; } if ( $height ) { $out .= 'height="' . (int) $height . '" '; } return $out; }
function image_hwstring( $width, $height ) {
	$out = '';
	if ( $width ) {
		$out .= 'width="' . (int) $width . '" ';
	}
	if ( $height ) {
		$out .= 'height="' . (int) $height . '" ';
	}
	return $out;
}

常見問題

FAQs
檢視更多 >