Use proxy-only urls for all ActiveStorage images

This commit is contained in:
Eric Schultz 2021-01-05 15:57:24 -06:00 committed by Eric Schultz
parent 4819ff3c7e
commit 3d92560e7a
19 changed files with 28 additions and 28 deletions

View file

@ -9,5 +9,5 @@ json.extract! nonprofit, :id, :name, #basics
:no_anon #options
json.url nonprofit_path(nonprofit)
json.logo do
json.normal url_for(nonprofit.logo_by_size(:normal))
json.normal rails_storage_proxy_url(nonprofit.logo_by_size(:normal))
end

View file

@ -4,4 +4,4 @@
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
json.extract! profile, :id, :name, :country, :picture
json.url profile_path(profile)
json.pic_tiny url_for(profile.picture_by_size(:tiny)) if profile.picture.attached?
json.pic_tiny rails_storage_proxy_url(profile.picture_by_size(:tiny)) if profile.picture.attached?

View file

@ -12,15 +12,15 @@ json.url campaign_url(nonprofit)
if campaign.main_image.attached?
json.main_image do
json.full url_for(campaign.main_image)
json.normal url_for(campaign.main_image_by_size(:normal))
json.thumb url_for(campaign.main_image_by_size(:thumb))
json.full rails_storage_proxy_url(campaign.main_image)
json.normal rails_storage_proxy_url(campaign.main_image_by_size(:normal))
json.thumb rails_storage_proxy_url(campaign.main_image_by_size(:thumb))
end
end
if campaign.background_image.attached?
json.background_image do
json.full url_for(campaign.background_image)
json.normal url_for(campaign.background_image_by_size(:normal))
json.full rails_storage_proxy_url(campaign.background_image)
json.normal rails_storage_proxy_url(campaign.background_image_by_size(:normal))
end
end

View file

@ -69,7 +69,7 @@
<label>Main Image <small>(at least 500x400)</small></label>
<p><small>Used for previews and social media</small></p>
<div class='image-upload u-inlineBlock' style='background-image: url("<%= @campaign.main_image.attached?
? url_for(@campaign.main_image_by_size(:thumb)) : '' %>");'>
? rails_storage_proxy_url(@campaign.main_image_by_size(:thumb)) : '' %>");'>
<span><i class='fa fa-pencil'></i> Edit</span>
<input type='file' name='campaign[main_image]'>
</div>

View file

@ -46,13 +46,13 @@
<%= content_for :facebook_tags do %>
<meta property="og:title" content="<%= raw @campaign.name %>">
<meta property="og:description" content="<%= @campaign.summary.present? ? raw(@campaign.summary) : raw(@campaign.name) %>">
<meta property="og:image" content="<%= @campaign.main_image.attached? ? @campaign.main_image_by_size(:normal) : "" %>">
<meta property="og:image" content="<%= @campaign.main_image.attached? ? rails_storage_proxy_url(@campaign.main_image_by_size(:normal)) : "" %>">
<% end %>
<%= content_for :twitter_tags do %>
<meta property="twitter:title" content="<%= raw @campaign.name %>">
<meta property="twitter:description" content="<%= raw @campaign.summary %>">
<meta property="twitter:image" content="<%= @campaign.main_image.attached? ? @campaign.main_image_by_size(:normal) : "" %>">
<meta property="twitter:image" content="<%= @campaign.main_image.attached? ? rails_storage_proxy_url(@campaign.main_image_by_size(:normal)) : "" %>">
<% end %>
<% if current_campaign_editor? %>

View file

@ -85,7 +85,7 @@
<fieldset class='u-marginTop--5'>
<label>Preview Image</label>
<p><small>Used for sharing on social media</small></p>
<div class='image-upload u-inlineBlock' style='background-image: url("<%= @event.main_image.attached? ? url_for(@event.main_image_by_size(:thumb)) : '' %>")'>
<div class='image-upload u-inlineBlock' style='background-image: url("<%= @event.main_image.attached? ? rails_storage_proxy_url(@event.main_image_by_size(:thumb))) : '' %>")'>
<span><i class='fa fa-pencil'></i> Edit</span>
<input type='file' name='event[main_image]'>
</div>

View file

@ -10,13 +10,13 @@
<%= content_for :facebook_tags do %>
<meta property="og:title" content="<%= raw @event.name %>" />
<meta property="og:description" content="<%= @event.summary.present? ? raw(@event.summary) : raw(@event.name) %>" />
<meta property="og:image" content="<%= @event.main_image.attached? ? @event.main_image_by_size(:normal) : "" %>" />
<meta property="og:image" content="<%= @event.main_image.attached? ? rails_storage_proxy_url(@event.main_image_by_size(:normal)) : "" %>" />
<% end %>
<%= content_for :twitter_tags do %>
<meta property="twitter:title" content="<%= raw @event.name %>" />
<meta property="twitter:description" content="<%= raw @event.summary %>" />
<meta property="twitter:image" content="<%= @event.main_image.attached? ? @event.main_image_by_size(:normal) : "" %>" />
<meta property="twitter:image" content="<%= @event.main_image.attached? ? rails_storage_proxy_url(@event.main_image_by_size(:normal)) : "" %>" />
<% end %>
<%= content_for :javascripts do %>

View file

@ -9,13 +9,13 @@
<%= content_for :facebook_tags do %>
<meta property="og:title" content="<%= raw @event.name %>" />
<meta property="og:description" content="<%= raw @event.summary %>" />
<meta property="og:image" content="<%= @event.main_image.attached? ? @event.main_image_by_size(:normal) : "" %>" />
<meta property="og:image" content="<%= @event.main_image.attached? ? rails_storage_proxy_url(@event.main_image_by_size(:normal)) : "" %>" />
<% end %>
<%= content_for :twitter_tags do %>
<meta property="twitter:title" content="<%= raw @event.name %>" />
<meta property="twitter:description" content="<%= raw @event.summary %>" />
<meta property="twitter:image" content="<%= @event.main_image.attached? ? @event.main_image_by_size(:normal) : "" %>" />
<meta property="twitter:image" content="<%= @event.main_image.attached? ? rails_storage_proxy_url(@event.main_image_by_size(:normal)) : "" %>" />
<% end %>
<%= content_for :javascripts do %>

View file

@ -3,7 +3,7 @@
<% if current_role?([:nonprofit_admin,:nonprofit_associate]) %>
<section class='sideNav-section'>
<a class='sideNav-link' href='<%= administered_nonprofit.url%>'>
<%= image_tag administered_nonprofit.logo_by_size(:small), class:"sideNav-profile" %>
<%= image_tag rails_storage_proxy_url(administered_nonprofit.logo_by_size(:small)), class:"sideNav-profile" %>
<span class='sideNav-text'><%= administered_nonprofit.name %></span>
</a>

View file

@ -5,7 +5,7 @@
<section class='sideNav-section'>
<a class='sideNav-link' href='<%= profile_url(current_user.profile) %>'>
<% if current_user.profile.picture.attached? %>
<%= image_tag current_user.profile.picture_by_size(:tiny), class: 'sideNav-profile' %>
<%= image_tag rails_storage_proxy_url(current_user.profile.picture_by_size(:tiny)), class: 'sideNav-profile' %>
<% else %>
<i class="sideNav-icon icon-user-1"></i>
<% end %>

View file

@ -99,7 +99,7 @@
<div class='layout--two'>
<fieldset>
<label class='u-marginBottom--10'>Logo</label>
<div class='image-upload u-margin--0' style='background-image:url("<%= @nonprofit.logo.attached? ? url_for(@nonprofit.logo_by_size(:normal)) : '' %>")'>
<div class='image-upload u-margin--0' style='background-image:url("<%= @nonprofit.logo.attached? ? rails_storage_proxy_url(@nonprofit.logo_by_size(:normal)) : '' %>")'>
<span><i class='fa fa-image'></i> Upload</span>
<input type='file' name='nonprofit[logo]'>
</div>

View file

@ -4,7 +4,7 @@
<table>
<tr>
<td class='fundraisingHeader-content-sideElementTd'>
<div class='fundraisingHeader-content-logo' style="background-image:url('<%= @nonprofit.logo.attached? ? url_for(@nonprofit.logo_by_size(:normal)) : "" %>');">
<div class='fundraisingHeader-content-logo' style="background-image:url('<%= @nonprofit.logo.attached? ? rails_storage_proxy_url(@nonprofit.logo_by_size(:normal)) : "" %>');">
</div>
</td>
<td class='fundraisingHeader-content-textTd'>

View file

@ -6,7 +6,7 @@
<div>
<div style='overflow: hidden; height: initial;'>
<%= image_tag @nonprofit.main_image_by_size(:nonprofit_carousel) %>
<%= image_tag rails_storage_proxy_url(@nonprofit.main_image_by_size(:nonprofit_carousel)) %>
</div>
</div>

View file

@ -24,7 +24,7 @@
</p>
<div class='u-inlineBlock'>
<div class='image-upload' style='background-image:url("<%= @nonprofit.main_image.attached? ? url_for(@nonprofit.main_image_by_size(:thumb_explore)) : '' %>")'>
<div class='image-upload' style='background-image:url("<%= @nonprofit.main_image.attached? ? rails_storage_proxy_url(@nonprofit.main_image_by_size(:thumb_explore)) : '' %>")'>
<span><i class='fa fa-image'></i> Select</span>
<input type='file' name='nonprofit[main_image]'>
</div>

View file

@ -34,13 +34,13 @@
<%= content_for :facebook_tags do %>
<meta property='og:title' content='I support <%= @nonprofit.name %>!'>
<meta property='og:description' content='<%= @nonprofit.summary %>'>
<meta property='og:image' content='<%= @nonprofit.main_image.attached? ? @nonprofit.main_image_by_size(:nonprofit_carousel) : "" %>'>
<meta property='og:image' content='<%= @nonprofit.main_image.attached? ? rails_storage_proxy_url(@nonprofit.main_image_by_size(:nonprofit_carousel) : "" %>'>
<% end %>
<%= content_for :twitter_tags do %>
<meta property="twitter:title" content="I support <%= raw @nonprofit.name %>!">
<meta property="twitter:description" content="<%= raw @nonprofit.summary %>">
<meta property="twitter:image" content="<%= @nonprofit.main_image.attached? ? @nonprofit.main_image_by_size(:nonprofit_carousel) : "" %>" />
<meta property="twitter:image" content="<%= @nonprofit.main_image.attached? ? rails_storage_proxy_url(@nonprofit.main_image_by_size(:nonprofit_carousel)) : "" %>" />
<% end %>
<% content_for :body_id do %>donate<% end %>

View file

@ -31,7 +31,7 @@
<tr>
<% if @nonprofit.logo.attached? %>
<td style='width: 100px; padding: 10px;'>
<%= image_tag @nonprofit.logo_by_size(:normal), style:'border: 1px solid rgba(0,0,0,0.05);'%>
<%= image_tag rails_storage_proxy_url(@nonprofit.logo_by_size(:normal)), style:'border: 1px solid rgba(0,0,0,0.05);'%>
</td>
<% end %>

View file

@ -8,12 +8,12 @@
<%= content_for :facebook_tags do %>
<meta property="og:title" content="<%= raw @nonprofit.name %>" />
<meta property="og:description" content="<%= raw @nonprofit.tagline %>" />
<meta property="og:image" content="<%= @nonprofit.main_image.attached? ? @nonprofit.main_image_by_size(:nonprofit_carousel) : "" %>" />
<meta property="og:image" content="<%= @nonprofit.main_image.attached? ? rails_storage_proxy_url(@nonprofit.main_image_by_size(:nonprofit_carousel)) : "" %>" />
<% end %>
<%= content_for :twitter_tags do %>
<meta property="twitter:title" content="<%= raw @nonprofit.name %>" />
<meta property="twitter:description" content="<%= raw @nonprofit.tagline %>" />
<meta property="twitter:image" content="<%= @nonprofit.main_image.attached? ? @nonprofit.main_image_by_size(:nonprofit_carousel) : "" %>" />
<meta property="twitter:image" content="<%= @nonprofit.main_image.attached? ? rails_storage_proxy_url(@nonprofit.main_image_by_size(:nonprofit_carousel)) : "" %>" />
<% end %>
<%= content_for :stylesheets do %>

View file

@ -18,7 +18,7 @@
<br>
<% if @nonprofit.logo.attached? %>
<%= image_tag url_for(@nonprofit.logo_by_size(:normal)) %>
<%= image_tag rails_storage_proxy_url(@nonprofit.logo_by_size(:normal)) %>
<% end %>
<% if params[:title] %>
<h4><%= params[:title] %></h4>

View file

@ -15,7 +15,7 @@
<table>
<tr>
<td>
<span class='donorProfileHeader-photo' style="background-image: url('<%= @profile.picture.attached? && url_for(@profile.picture_by_size(:normal)) %>');"></span>
<span class='donorProfileHeader-photo' style="background-image: url('<%= @profile.picture.attached? && rails_storage_proxy_url(@profile.picture_by_size(:normal)) %>');"></span>
</td>
<td class='u-paddingLeft--15'>
<% supporter = (@profile.supporters && @profile.supporters.length != 0) ? supporter : false %>