image_align_input_fields() – Retrieve HTML for the image alignment radio buttons with the specified one checked.

You appear to be a bot. Output may be restricted

Description

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

Usage

$string = image_align_input_fields( $post, $checked );

Parameters

$post
( WP_Post ) required
$checked
( string ) optional

Returns

string

Source

File name: wordpress/wp-admin/includes/media.php
Lines:

1 to 28 of 28
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 );
}
 

 View on GitHub View on Trac