<% if @file.valid? %>
  <% klass = @file.class.name.split('::').last.to_css_class %>
  jQuery("#published-media .items .<%= klass.pluralize %>").append("<%= j render :partial => "cms/media_panel/#{klass}" %>");
  jQuery("#published-media .items .<%= klass.pluralize %>").show();
<% else %>
  alert("Failed to upload file: <%= j @file.errors.full_messages.join(', ').html_safe %>");
<% end %>

<% if @file.valid? %>
  <% klass = @file.class.name.split('::').last.to_css_class %>
  jQuery("#published-media .items .<%= klass.pluralize %> h3").after("<%= j render :partial => "cms/media_panel/#{klass}" %>");
  jQuery("#published-media .items .<%= klass.pluralize %>").show();
<% else %>
  alert("Failed to upload file: <%= j @file.errors.full_messages.join(', ').html_safe %>");
<% end %>

Insert uploaded media before the others
[media-panel-improvements] Insert uploaded media before the others
