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 @@

Used for previews and social media

-
+
");'> Edit
diff --git a/app/views/campaigns/show.html.erb b/app/views/campaigns/show.html.erb index 1bea0da4..c44382ed 100644 --- a/app/views/campaigns/show.html.erb +++ b/app/views/campaigns/show.html.erb @@ -20,7 +20,7 @@ app.is_parent_campaign = <%= @campaign.parent_campaign? %> appl.def('has_video', <%= @campaign.video_url.present? %>) appl.def('campaign_is_deleted', <%= @campaign.deleted || false %>) - appl.def('has_main_image', <%= @campaign.main_image.file.present? %>) + appl.def('has_main_image', <%= @campaign.main_image.attached? %>) <%= render 'schema', campaign: @campaign, url: @url %> @@ -45,13 +45,13 @@ <%= content_for :facebook_tags do %> - + "> <% end %> <%= content_for :twitter_tags do %> - + "> <% end %> <% if current_campaign_editor? %> diff --git a/app/views/events/_edit_form.html.erb b/app/views/events/_edit_form.html.erb index 3c3eb9da..a0d7548e 100644 --- a/app/views/events/_edit_form.html.erb +++ b/app/views/events/_edit_form.html.erb @@ -84,7 +84,7 @@

Used for sharing on social media

-
+
")'> Edit
diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb index 91c555f9..8f7cd92c 100644 --- a/app/views/events/show.html.erb +++ b/app/views/events/show.html.erb @@ -9,13 +9,13 @@ <%= content_for :facebook_tags do %> - + " /> <% end %> <%= content_for :twitter_tags do %> - + " /> <% end %> <%= content_for :javascripts do %> diff --git a/app/views/events/stats.html.erb b/app/views/events/stats.html.erb index 025bb382..755f260e 100644 --- a/app/views/events/stats.html.erb +++ b/app/views/events/stats.html.erb @@ -8,13 +8,13 @@ <%= content_for :facebook_tags do %> - + " /> <% end %> <%= content_for :twitter_tags do %> - + " /> <% end %> <%= content_for :javascripts do %> diff --git a/app/views/layouts/_admin_menu.html.erb b/app/views/layouts/_admin_menu.html.erb index 3f04c1b4..548f194b 100644 --- a/app/views/layouts/_admin_menu.html.erb +++ b/app/views/layouts/_admin_menu.html.erb @@ -2,7 +2,7 @@ <% if current_role?([:nonprofit_admin,:nonprofit_associate]) %>
- + <%= image_tag administered_nonprofit.logo_by_size(:small), class:"sideNav-profile" %> <%= administered_nonprofit.name %> diff --git a/app/views/layouts/_user_menu.html.erb b/app/views/layouts/_user_menu.html.erb index 1f8bb3b3..b6ec1308 100644 --- a/app/views/layouts/_user_menu.html.erb +++ b/app/views/layouts/_user_menu.html.erb @@ -3,8 +3,8 @@
- <% if current_user.profile.picture? %> - + <% if current_user.profile.picture.attached? %> + <%= image_tag current_user.profile.picture_by_size(:tiny), class: 'sideNav-profile' %> <% else %> <% end %> diff --git a/app/views/nonprofits/_edit.html.erb b/app/views/nonprofits/_edit.html.erb index 0132e14b..08a8343a 100644 --- a/app/views/nonprofits/_edit.html.erb +++ b/app/views/nonprofits/_edit.html.erb @@ -98,7 +98,7 @@
-
+
")'> Upload
diff --git a/app/views/nonprofits/_header_content.html.erb b/app/views/nonprofits/_header_content.html.erb index 9514d4cf..c45298b3 100644 --- a/app/views/nonprofits/_header_content.html.erb +++ b/app/views/nonprofits/_header_content.html.erb @@ -3,7 +3,7 @@
- diff --git a/app/views/nonprofits/_overview_media.html.erb b/app/views/nonprofits/_overview_media.html.erb index 02172a7d..28437a5f 100644 --- a/app/views/nonprofits/_overview_media.html.erb +++ b/app/views/nonprofits/_overview_media.html.erb @@ -1,11 +1,11 @@ <%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%>
- <% if @nonprofit.main_image.file %> + <% if @nonprofit.main_image.attached? %>
- <%= image_tag @nonprofit.main_image_url(:nonprofit_carousel).to_s %> + <%= image_tag @nonprofit.main_image_by_size(:nonprofit_carousel) %>
diff --git a/app/views/nonprofits/_settings_modals.html.erb b/app/views/nonprofits/_settings_modals.html.erb index 752a50ff..1660a9ad 100644 --- a/app/views/nonprofits/_settings_modals.html.erb +++ b/app/views/nonprofits/_settings_modals.html.erb @@ -23,7 +23,7 @@

-
+
")'> Select
diff --git a/app/views/nonprofits/donate.html.erb b/app/views/nonprofits/donate.html.erb index 7ec3f2de..4cfc807e 100755 --- a/app/views/nonprofits/donate.html.erb +++ b/app/views/nonprofits/donate.html.erb @@ -33,13 +33,13 @@ <%= content_for :facebook_tags do %> - + <% end %> <%= content_for :twitter_tags do %> - + " /> <% end %> <% content_for :body_id do %>donate<% end %> diff --git a/app/views/nonprofits/email/_footer.html.erb b/app/views/nonprofits/email/_footer.html.erb index 95f12a86..3ea56a39 100644 --- a/app/views/nonprofits/email/_footer.html.erb +++ b/app/views/nonprofits/email/_footer.html.erb @@ -28,9 +28,9 @@ - <% if @nonprofit.logo_url %> + <% if @nonprofit.logo.attached? %> <% end %> diff --git a/app/views/nonprofits/show.html.erb b/app/views/nonprofits/show.html.erb index 41dd817e..87f5f881 100755 --- a/app/views/nonprofits/show.html.erb +++ b/app/views/nonprofits/show.html.erb @@ -7,12 +7,12 @@ <%= content_for :facebook_tags do %> - + " /> <% end %> <%= content_for :twitter_tags do %> - + " /> <% end %> <%= content_for :stylesheets do %> diff --git a/app/views/nonprofits/supporter_form.html.erb b/app/views/nonprofits/supporter_form.html.erb index c217d2db..dbe7ddbd 100644 --- a/app/views/nonprofits/supporter_form.html.erb +++ b/app/views/nonprofits/supporter_form.html.erb @@ -16,7 +16,9 @@
- <%= image_tag @nonprofit.logo_url(:normal).to_s %> + <% if @nonprofit.logo.attached? %> + <%= image_tag url_for(@nonprofit.logo_by_size(:normal)) %> + <% end %> <% if params[:title] %>

<%= params[:title] %>

<% else %> diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index 486fe7b7..9be77c1f 100644 --- a/app/views/profiles/show.html.erb +++ b/app/views/profiles/show.html.erb @@ -14,7 +14,7 @@
- + <%= image_tag @nonprofit.logo_by_size(:normal), style:'border: 1px solid rgba(0,0,0,0.05);'%>
- + <% supporter = (@profile.supporters && @profile.supporters.length != 0) ? supporter : false %>