public function formFields($fields, $post)
    {
        // Bail if its not edit attachment page
        if (!isset($_GET['post']) || $post->post_type !== 'attachment') {
            return $fields;
        }

        add_thickbox();
        wp_enqueue_media();
        $uploadDir = wp_upload_dir();

        $mime =  mime_content_type($uploadDir['basedir'] . '/' . get_post_meta(get_the_id(), '_wp_attached_file', true));

        // Media replace button
        $html = '<button type="button" class="button-secondary button-large" data-action="media-replacer-replace" data-mime="' . $mime . '" data-edit-link="' . get_edit_post_link($post->ID) . '">' . __('Replace media', 'media-replacer') . '</button>
                 <input type="hidden" name="media-replacer-replace-with">';

        // Revision button
        $revisions = get_post_meta($post->ID, self::$revisionMetaKey, true);
        if (!is_array($revisions)) {
            $revisions = array();
        }

        $revisions = array_reverse($revisions, true);

        if (count($revisions) > 0) {
            $html .= '<a href="#TB_inline?width=600&height=550&inlineId=media-replace-revisions-thickbox-' . $post->ID . '" class="thickbox button-secondary button-large" data-action="media-replacer-revisions" data-edit-link="' . get_edit_post_link($post->ID) . '">' . __('Media revisions', 'media-replacer') . '</a>';
            $html .= '<div id="media-replace-revisions-thickbox-' . $post->ID . '" style="display:none;"><ul class="media-replace-revisions">';
        }

        foreach ($revisions as $time => $path) {
            if (!file_exists($path)) {
                continue;
            }

            $url = str_replace($uploadDir['basedir'], $uploadDir['baseurl'], $path);

            $date = mysql2date('Y-m-d H:i', date('Y-m-d H:i:s', $time));
            $html .= '<li data-restore="' . $path . '">';

            if (explode('/', mime_content_type($path))[0] === 'image') {
                $html .= '<div class="media-replace-revision-thumb" style="background-image:url(' . $url . ')"></div>';
            }

            $html .= '<time>' . $date . '</time>';
            $html .= '</li>';
        }

        if (count($revisions)) {
            $html .= '</ul>
                <div class="media-replace-revision-footer">
                    <button type="button" class="button button-large" data-action="media-replace-close-thickbox">' . __('Cancel') . '</button>
                    <button type="button" class="button button-large button-primary" data-action="media-replace-close-thickbox">' . __('Ok') . '</button>
                </div>
            </div><input type="hidden" name="media-replace-restore">';
        }

        $fields['media_replacer'] = array(
            'label' => '',
            'input' => 'html',
            'html' => $html
        );

        return $fields;
    }