image_hwstring()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
image_hwstring( int|string $width, int|string $height ): string
Описание
Оба атрибута обязательны в том смысле, что оба параметра должны иметь значение, но необязательны в том смысле, что если задать им false или null, они не будут добавлены в возвращаемую строку.
Значение можно задать строкой, но приниматься будут только числовые значения.
Если добавить 'px' после чисел, оно будет удалено из возвращаемого результата.
Оригинал (английский)
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
обязательный
$height
int|string
обязательный
Возвращаемое значение
string
Исходный код
wp-includes/media.php:160
function image_hwstring( $width, $height ) {
$out = '';
if ( $width ) {
$out .= 'width="' . (int) $width . '" ';
}
if ( $height ) {
$out .= 'height="' . (int) $height . '" ';
}
return $out;
}
История изменений
| Версия | Описание |
|---|---|
| 2.5.0 | Introduced. |

