diff --git a/app/controllers/image_attachments_controller.rb b/app/controllers/image_attachments_controller.rb
index fc1d7b13..2d8683f1 100644
--- a/app/controllers/image_attachments_controller.rb
+++ b/app/controllers/image_attachments_controller.rb
@@ -6,16 +6,16 @@ class ImageAttachmentsController < ApplicationController
def create
# must return json with a link attr
# http://editor.froala.com/server-integrations/php-image-upload
- @image = ImageAttachment.new(file: params[:file])
+ @image = ImageAttachment.new(clean_params_create)
if @image.save
- render json: { link: @image.file_url }
+ render json: { link: url_for(@image.file) }
else
render json: @image.errors.full_messages, status: :unprocessable_entity
end
end
def remove
- @image = ImageAttachment.select { |img| img.file_url == params[:src] }.first
+ @image = ImageAttachment.select { |img| url_for(img.file) == clean_params_remove[:src] }.first
if @image
@image.destroy
render json: @image
@@ -23,4 +23,13 @@ class ImageAttachmentsController < ApplicationController
render json: {}, status: :unprocessable_entity
end
end
+
+ private
+ def clean_params_create
+ params.require(:file)
+ end
+
+ def clean_params_remove
+ params.require(:src)
+ end
end
diff --git a/app/controllers/nonprofits_controller.rb b/app/controllers/nonprofits_controller.rb
index a268f762..f38d0db8 100755
--- a/app/controllers/nonprofits_controller.rb
+++ b/app/controllers/nonprofits_controller.rb
@@ -28,7 +28,9 @@ class NonprofitsController < ApplicationController
@active_campaigns = campaigns.active
@any_past_campaigns = campaigns.past.any?
- @nonprofit_background_image = FetchBackgroundImage.with_model(@nonprofit)
+ @nonprofit_background_image = @nonprofit.background_image.attached? ?
+ url_for(@nonprofit.background_image_by_size(:normal)) :
+ url_for(Image::DefaultNonprofitUrl)
respond_to do |format|
format.html
diff --git a/app/views/campaigns/_campaign_media.html.erb b/app/views/campaigns/_campaign_media.html.erb
index afb4d256..ed2cf79c 100644
--- a/app/views/campaigns/_campaign_media.html.erb
+++ b/app/views/campaigns/_campaign_media.html.erb
@@ -11,7 +11,7 @@
<%= render 'components/media/youtube_iframe', id: @campaign.youtube_video_id %>
- <% elsif @campaign.main_image? %>
-
+ <% elsif @campaign.main_image.attached? %>
+ <%= image_tag @campaign.main_image_by_size(:normal), class: 'campaignMedia-image' %>
<% end %>
diff --git a/app/views/campaigns/_campaigns_table.html.erb b/app/views/campaigns/_campaigns_table.html.erb
index d2ead6ad..2de8e5f5 100644
--- a/app/views/campaigns/_campaigns_table.html.erb
+++ b/app/views/campaigns/_campaigns_table.html.erb
@@ -5,7 +5,9 @@
<% metric = QueryCampaignMetrics.on_donations(campaign.id) %>
-
+ <% if campaign.main_image.attached?%>
+ <%= image_tag campaign.main_image_by_size(:normal) %>
+ <% end %>
|
<% if campaign.end_datetime %>
diff --git a/app/views/campaigns/_settings_modal.html.erb b/app/views/campaigns/_settings_modal.html.erb
index f378e66f..ee8b5301 100644
--- a/app/views/campaigns/_settings_modal.html.erb
+++ b/app/views/campaigns/_settings_modal.html.erb
@@ -67,7 +67,8 @@
|