wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



block_core_gallery_is_valid_aspect_ratio › WordPress Function

Od7.1.0
Przestarzałyn/a
› block_core_gallery_is_valid_aspect_ratio ( $value )
Parametry:
  • (mixed) $value Value to check.
    Wymagane: Tak
Powrót:
  • (bool) Whether the value is a valid aspect ratio.
Zdefiniowane na:
Codex:

Returns whether a value can be used as a Gallery aspect ratio.

Aspect ratios are interpolated into a generated stylesheet instead of being set as an inline style, so only the numeric forms produced by aspect ratio presets (and auto) are accepted. A value from saved content that isn't one of those is ignored rather than emitted, so it can't close the rule early and inject declarations of its own. The editor applies the same restriction in isValidGalleryAspectRatio().


Źródło

function block_core_gallery_is_valid_aspect_ratio( $value ) {
	return is_string( $value ) && 1 === preg_match( '#^(auto|\d+(\.\d+)?(\s*/\s*\d+(\.\d+)?)?)$#', trim( $value ) );
}