image_align_input_fields() WordPress Function

The image_align_input_fields() function is used to align the input fields for an image. This is useful when the image is aligned to the left or right of the text.

image_align_input_fields( WP_Post $post, string $checked = '' ) #

Retrieves HTML for the image alignment radio buttons with the specified one checked.


Parameters

$post

(WP_Post)(Required)

$checked

(string)(Optional)

Default value: ''


Top ↑

Return

(string)


Top ↑

Source

File: wp-admin/includes/media.php

function image_align_input_fields( $post, $checked = '' ) {

	if ( empty( $checked ) ) {
		$checked = get_user_setting( 'align', 'none' );
	}

	$alignments = array(
		'none'   => __( 'None' ),
		'left'   => __( 'Left' ),
		'center' => __( 'Center' ),
		'right'  => __( 'Right' ),
	);

	if ( ! array_key_exists( (string) $checked, $alignments ) ) {
		$checked = 'none';
	}

	$out = array();

	foreach ( $alignments as $name => $label ) {
		$name  = esc_attr( $name );
		$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'" .
			( $checked == $name ? " checked='checked'" : '' ) .
			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
	}

	return implode( "\n", $out );
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More