edit_form_image_editor

The timeline below displays how wordpress function edit_form_image_editor has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = (int) $post->ID;
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if (str_starts_with($post->post_mime_type, 'image')) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<textarea class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description"><?php 
        echo esc_attr($alt_text);
        ?></textarea>
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Hidden accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 6.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = (int) $post->ID;
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<textarea class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description"><?php 
        echo esc_attr($alt_text);
        ?></textarea>
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Hidden accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 6.1

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = (int) $post->ID;
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<textarea class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description"><?php 
        echo esc_attr($alt_text);
        ?></textarea>
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.9

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = (int) $post->ID;
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Learn how to describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.6

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = (int) $post->ID;
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .10

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = intval($post->ID);
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = intval($post->ID);
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 3.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = intval($post->ID);
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 3.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = intval($post->ID);
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .10

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = intval($post->ID);
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    $attachment_id = intval($post->ID);
    if ($attachment_id) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = '';
        $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>
		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
		<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
		<?php 
        printf(
            /* translators: 1: Link to tutorial, 2: Additional link attributes, 3: Accessibility text. */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: Accessibility text. */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content" class="attachment-content-description"><strong><?php 
    _e('Description');
    ?></strong>
	<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 2.7

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link to tutorial, 2: additional link attributes, 3: accessibility text */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 2.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link to tutorial, 2: additional link attributes, 3: accessibility text */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .20

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link to tutorial, 2: additional link attributes, 3: accessibility text */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 2.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link to tutorial, 2: additional link attributes, 3: accessibility text */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .10

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link to tutorial, 2: additional link attributes, 3: accessibility text */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 2.1

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link to tutorial, 2: additional link attributes, 3: accessibility text */
            __('<a href="%1$s" %2$s>Describe the purpose of the image%3$s</a>. Leave empty if the image is purely decorative.'),
            esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree'),
            'target="_blank" rel="noopener noreferrer"',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            )
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p class="attachment-alt-text">
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
		<p class="attachment-alt-text-description" id="alt-text-description">
			<?php 
        printf(
            /* translators: 1: link start tag, 2: accessibility text, 3: link end tag */
            __('%1$sDescribe the purpose of the image%2$s%3$s. Leave empty if the image is purely decorative.'),
            '<a href="' . esc_url('https://www.w3.org/WAI/tutorials/images/decision-tree') . '" target="_blank" rel="noopener noreferrer">',
            sprintf(
                '<span class="screen-reader-text"> %s</span>',
                /* translators: accessibility text */
                __('(opens in a new tab)')
            ),
            '</a>'
        );
        ?>
		</p>
	<?php 
    }
    ?>

		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
		<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 1.6

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
														<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 1.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
														<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .10

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
														<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.1

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        $open_style = $not_open_style = '';
        if ($open) {
            $open_style = ' style="display:none"';
        } else {
            $not_open_style = ' style="display:none"';
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        echo $open_style;
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        echo $not_open_style;
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
		<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong>
														<?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 0.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .20

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 0.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .10

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 9.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .20

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 9.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .15

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.7

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } elseif (isset($thumb_url[0])) {
        ?>
		<div class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>">
				<img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" />
			</p>
		</div>
		<?php 
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 6.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .20

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 6.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .19

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.6

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    } else {
        /**
         * Fires when an attachment type can't be rendered in the edit form.
         *
         * @since 4.6.0
         *
         * @param WP_Post $post A post object.
         */
        do_action('wp_edit_form_attachment_display', $post);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .30

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 5.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .22

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.5

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 *
 * @param WP_Post $post A post object.
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder wp-clearfix">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image wp-clearfix" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .30

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .23

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="attachment_content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 3.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .30

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 3.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .24

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 2.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .30

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 2.3

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .28

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.2

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && wp_attachment_is('audio', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && wp_attachment_is('video', $post)) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 1.5

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .40

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 1.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .31

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 0.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .31

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?>
	</label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 4.0

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        $thumb_id = get_post_thumbnail_id($attachment_id);
        if (!empty($thumb_id)) {
            $attr['poster'] = wp_get_attachment_url($thumb_id);
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 3.9

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        wp_maybe_generate_attachment_metadata($post);
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        wp_maybe_generate_attachment_metadata($post);
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 640) : 0;
        $h = (!empty($meta['height'])) ? $meta['height'] : 0;
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($w) && !empty($h)) {
            $attr['width'] = $w;
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>


	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong><?php 
    if (preg_match('#^(audio|video)/#', $post->post_mime_type)) {
        echo ': ' . __('Displayed on attachment pages.');
    }
    ?></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 8.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .34

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 7.5

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .40

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 7.4

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: .34

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor(format_to_edit($post->post_content), 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}

WordPress Version: 3.7

/**
 * Displays the image and editor in the post editor
 *
 * @since 3.5.0
 */
function edit_form_image_editor($post)
{
    $open = isset($_GET['image-editor']);
    if ($open) {
        require_once ABSPATH . 'wp-admin/includes/image-edit.php';
    }
    $thumb_url = false;
    if ($attachment_id = intval($post->ID)) {
        $thumb_url = wp_get_attachment_image_src($attachment_id, array(900, 450), true);
    }
    $filename = esc_html(basename($post->guid));
    $title = esc_attr($post->post_title);
    $alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
    $att_url = wp_get_attachment_url($post->ID);
    ?>
	<div class="wp_attachment_holder">
	<?php 
    if (wp_attachment_is_image($post->ID)) {
        $image_edit_button = '';
        if (wp_image_editor_supports(array('mime_type' => $post->post_mime_type))) {
            $nonce = wp_create_nonce("image_editor-{$post->ID}");
            $image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open( {$post->ID}, \"{$nonce}\" )' class='button' value='" . esc_attr__('Edit Image') . "' /> <span class='spinner'></span>";
        }
        ?>

		<div class="imgedit-response" id="imgedit-response-<?php 
        echo $attachment_id;
        ?>"></div>

		<div<?php 
        if ($open) {
            echo ' style="display:none"';
        }
        ?> class="wp_attachment_image" id="media-head-<?php 
        echo $attachment_id;
        ?>">
			<p id="thumbnail-head-<?php 
        echo $attachment_id;
        ?>"><img class="thumbnail" src="<?php 
        echo set_url_scheme($thumb_url[0]);
        ?>" style="max-width:100%" alt="" /></p>
			<p><?php 
        echo $image_edit_button;
        ?></p>
		</div>
		<div<?php 
        if (!$open) {
            echo ' style="display:none"';
        }
        ?> class="image-editor" id="image-editor-<?php 
        echo $attachment_id;
        ?>">
			<?php 
        if ($open) {
            wp_image_editor($attachment_id);
        }
        ?>
		</div>
	<?php 
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'audio/')) {
        echo wp_audio_shortcode(array('src' => $att_url));
    } elseif ($attachment_id && 0 === strpos($post->post_mime_type, 'video/')) {
        $meta = wp_get_attachment_metadata($attachment_id);
        $w = (!empty($meta['width'])) ? min($meta['width'], 600) : 0;
        $h = 0;
        if (!empty($meta['height'])) {
            $h = $meta['height'];
        }
        if ($h && $w < $meta['width']) {
            $h = round($meta['height'] * $w / $meta['width']);
        }
        $attr = array('src' => $att_url);
        if (!empty($meta['width'])) {
            $attr['width'] = $w;
        }
        if (!empty($meta['height'])) {
            $attr['height'] = $h;
        }
        echo wp_video_shortcode($attr);
    }
    ?>
	</div>
	<div class="wp_attachment_details edit-form-section">
		<p>
			<label for="attachment_caption"><strong><?php 
    _e('Caption');
    ?></strong></label><br />
			<textarea class="widefat" name="excerpt" id="attachment_caption"><?php 
    echo $post->post_excerpt;
    ?></textarea>
		</p>

	<?php 
    if ('image' === substr($post->post_mime_type, 0, 5)) {
        ?>
		<p>
			<label for="attachment_alt"><strong><?php 
        _e('Alternative Text');
        ?></strong></label><br />
			<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php 
        echo esc_attr($alt_text);
        ?>" />
		</p>
	<?php 
    }
    ?>

	<?php 
    $quicktags_settings = array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close');
    $editor_args = array('textarea_name' => 'content', 'textarea_rows' => 5, 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings);
    ?>

	<label for="content"><strong><?php 
    _e('Description');
    ?></strong></label>
	<?php 
    wp_editor($post->post_content, 'attachment_content', $editor_args);
    ?>

	</div>
	<?php 
    $extras = get_compat_media_markup($post->ID);
    echo $extras['item'];
    echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n";
}