image_hwstring() - WordPress 函数参考中文文档

返回介绍

image_hwstring()

发布于 2017-09-11 字数1719 浏览 1038 评论 0

image_hwstring( int|string $width,  int|string $height )

Retrieve 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.


参数

$width

(int|string)
(Required)
Image width in pixels.

$height

(int|string)
(Required)
Image height in pixels.


返回值

(string) HTML attributes for width and, or height.


源代码

File: wp-includes/media.php

function image_hwstring( $width, $height ) {
	$out = '';
	if ($width)
		$out .= 'width="'.intval($width).'" ';
	if ($height)
		$out .= 'height="'.intval($height).'" ';
	return $out;
}

更新日志

Version 描述
2.5.0 Introduced.

相关函数

Used By

  • wp-includes/media.php:
    get_image_tag()
  • wp-includes/media.php:
    wp_get_attachment_image()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!