<commit_before><%= simple_form_for([:admin, @media_item]) do |f| %>
  <%# TODO: replace with shared form error notification helper or partial %>
  <%= f.error_notification %>
  <% if @media_item.errors[:base].present? %>
    <div class="alert alert-danger">
      <%= f.error :base %>
    </div>
  <% end %>
  <div class="row small-gutters">
    <%= render 'admin/shared/edit/sidebar', f: f, record: @media_item %>
    <div class="col-md-9">
      <%= render 'admin/shared/localization/nav_tabs' %>
      <div class="card">
        <h1 class="h2 card-header">Metadata</h1>
        <div class="card-body">
          <div class="form-inputs">
            <div class="row small-gutters">
              <div class="col-md-6 tab-content">
                <%= f.input :title, placeholder: 'The title will be generated automatically from the file name if left blank.', hint: 'The title is used to identify the image on the backend. It is not usually visible to the user, and typically you do not need to edit this field.' %>
                <%= render 'admin/form_inputs/slug', f: f %>
                <% I18n.available_locales.each_with_index do |locale, index| %>
                  <%= content_tag :div, class: "locale-panel #{'display-none' unless index.zero?}", data: { locale: locale } do %>
                    <%= localized_input f, :alternative_text, locale, hint: 'The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).' %>
                    <%= localized_input f, :caption, locale, markdown: true %>
                  <% end %>
                <% end %>
                <%= f.button :submit, class: 'btn-success' %>
              </div>
              <div class="col-md-6 file-upload-wrapper">
                <div class="file-upload">
                  <label>File Upload</label>
                  <%= f.hidden_field :attachment, value: @media_item.cached_attachment_data, class: 'file-upload__data' %>
                  <%= f.file_field :attachment, class: 'file-upload__file' %>
                </div>

                <div class="form-group">
                  <div class="file-upload-notifications"></div>
                  <div class="upload-preview">
                    <% if @media_item.try(:image?) && @media_item.try(:point_of_interest_x).present? && @media_item.try(:point_of_interest_y).present? %>
                      <label class="media-item__point-of-interest__label">Point of Interest</label>
                      <div id="media-item__point-of-interest" class="media-item__point-of-interest">
                        <%= content_tag :div, nil, id: 'media-item__point-of-interest__crosshair', class: 'media-item__point-of-interest__crosshair', style: "top: #{@media_item.point_of_interest_y}%; left: #{@media_item.point_of_interest_x}%;" %>
                        <%= image_tag @media_item.attachment_url(:medium) %>
                        <%= f.input :point_of_interest_x, as: :hidden %>
                        <%= f.input :point_of_interest_y, as: :hidden %>
                      </div>
                      <small class="form-text text-muted">Click the image to change the point of interest of the image. The point of interest is used to determine where to crop the image in some contexts.</small>
                    <% elsif @media_item.try(:image?) %>
                      <%= image_tag @media_item.attachment_url(:medium).presence || uri_image_placeholder %>
                    <% elsif @media_item.try(:video?) %>
                      <%= video_tag @media_item.attachment_url, controls: true %>
                    <% elsif @media_item.try(:file?) %>
                      <div class="mt-2">
                        <%= bootstrap_icon 'file-richtext', style: 'width: 36px;' %>
                        <%= @media_item.attachment_file_name.presence || @media_item.title %>
                      </div>
                    <% end %>
                  </div>

                </div>
                <% if @media_item.attachment.present? %>
                  <div class="form-group">
                    <label class="control-label">Attachment URLs:</label>
                    <% if @media_item.image? %>
                      <ul>
                        <li><%= link_to 'Original', @media_item.attachment_url, target: '_blank' %></li>
                        <li><%= link_to 'Large', @media_item.attachment_url(:large), target: '_blank' %></li>
                        <li><%= link_to 'Medium', @media_item.attachment_url(:medium), target: '_blank' %></li>
                        <li><%= link_to 'Small', @media_item.attachment_url(:small), target: '_blank' %></li>
                      </ul>
                    <% else %>
                      <ul>
                        <li><%= link_to 'Original', @media_item.attachment_url %></li>
                      </ul>
                    <% end %>
                  </div>
                <% end %>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<% end %><commit_msg>Don't show media icon preview for new records<commit_after><%= simple_form_for([:admin, @media_item]) do |f| %>
  <%# TODO: replace with shared form error notification helper or partial %>
  <%= f.error_notification %>
  <% if @media_item.errors[:base].present? %>
    <div class="alert alert-danger">
      <%= f.error :base %>
    </div>
  <% end %>
  <div class="row small-gutters">
    <%= render 'admin/shared/edit/sidebar', f: f, record: @media_item %>
    <div class="col-md-9">
      <%= render 'admin/shared/localization/nav_tabs' %>
      <div class="card">
        <h1 class="h2 card-header">Metadata</h1>
        <div class="card-body">
          <div class="form-inputs">
            <div class="row small-gutters">
              <div class="col-md-6 tab-content">
                <%= f.input :title, placeholder: 'The title will be generated automatically from the file name if left blank.', hint: 'The title is used to identify the image on the backend. It is not usually visible to the user, and typically you do not need to edit this field.' %>
                <%= render 'admin/form_inputs/slug', f: f %>
                <% I18n.available_locales.each_with_index do |locale, index| %>
                  <%= content_tag :div, class: "locale-panel #{'display-none' unless index.zero?}", data: { locale: locale } do %>
                    <%= localized_input f, :alternative_text, locale, hint: 'The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).' %>
                    <%= localized_input f, :caption, locale, markdown: true %>
                  <% end %>
                <% end %>
                <%= f.button :submit, class: 'btn-success' %>
              </div>
              <div class="col-md-6 file-upload-wrapper">
                <div class="file-upload">
                  <label>File Upload</label>
                  <%= f.hidden_field :attachment, value: @media_item.cached_attachment_data, class: 'file-upload__data' %>
                  <%= f.file_field :attachment, class: 'file-upload__file' %>
                </div>

                <div class="form-group">
                  <div class="file-upload-notifications"></div>
                  <% unless @media_item.new_record? %>
                    <div class="upload-preview">
                      <% if @media_item.try(:image?) && @media_item.try(:point_of_interest_x).present? && @media_item.try(:point_of_interest_y).present? %>
                        <label class="media-item__point-of-interest__label">Point of Interest</label>
                        <div id="media-item__point-of-interest" class="media-item__point-of-interest">
                          <%= content_tag :div, nil, id: 'media-item__point-of-interest__crosshair', class: 'media-item__point-of-interest__crosshair', style: "top: #{@media_item.point_of_interest_y}%; left: #{@media_item.point_of_interest_x}%;" %>
                          <%= image_tag @media_item.attachment_url(:medium) %>
                          <%= f.input :point_of_interest_x, as: :hidden %>
                          <%= f.input :point_of_interest_y, as: :hidden %>
                        </div>
                        <small class="form-text text-muted">Click the image to change the point of interest of the image. The point of interest is used to determine where to crop the image in some contexts.</small>
                      <% elsif @media_item.try(:image?) %>
                        <%= image_tag @media_item.attachment_url(:medium).presence || uri_image_placeholder %>
                      <% elsif @media_item.try(:video?) %>
                        <%= video_tag @media_item.attachment_url, controls: true %>
                      <% elsif @media_item.try(:file?) %>
                        <div class="mt-2">
                          <%= bootstrap_icon 'file-richtext', style: 'width: 36px;' %>
                          <%= @media_item.attachment_file_name.presence || @media_item.title %>
                        </div>
                      <% end %>
                    </div>
                  <% end %>

                </div>
                <% if @media_item.attachment.present? %>
                  <div class="form-group">
                    <label class="control-label">Attachment URLs:</label>
                    <% if @media_item.image? %>
                      <ul>
                        <li><%= link_to 'Original', @media_item.attachment_url, target: '_blank' %></li>
                        <li><%= link_to 'Large', @media_item.attachment_url(:large), target: '_blank' %></li>
                        <li><%= link_to 'Medium', @media_item.attachment_url(:medium), target: '_blank' %></li>
                        <li><%= link_to 'Small', @media_item.attachment_url(:small), target: '_blank' %></li>
                      </ul>
                    <% else %>
                      <ul>
                        <li><%= link_to 'Original', @media_item.attachment_url %></li>
                      </ul>
                    <% end %>
                  </div>
                <% end %>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <% if @media_item.vimeo_video? && lookup_context.exists?('admin/shared/forest/vimeo/vimeo_data', [], true) %>
    <%= render 'admin/shared/forest/vimeo/vimeo_data', f: f, record: @media_item %>
  <% end %>
<% end %>
{'fraction_non_alphanumeric': 0.1438195938991298, 'fraction_numerical': 0.002058575839805371, 'mean_word_length': 1.8089356110381078, 'pattern_counts': {'":': 0, '<': 206, '<?xml version=': 0, '>': 206, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '401122', 'n_tokens_mistral': 3189, 'n_tokens_neox': 2882, 'n_words': 711}