Skip to content

Commit 02d3fc4

Browse files
committed
Fix images/favicons for newsletters (cells)
1 parent 74f1319 commit 02d3fc4

2 files changed

Lines changed: 57 additions & 5 deletions

File tree

app/cells/decidim/newsletter_templates/test/show.erb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ table.button table td {
2424
<tr>
2525
<th>
2626
<center>
27-
<%= render partial: "layouts/decidim/mailer_logo.html", locals: { organization: organization } %>
27+
<%=
28+
self.class.view_paths = [Rails.root.join('app/views'), *self.class.view_paths]
29+
render partial: "layouts/decidim/mailer_logo.html", locals: { organization: organization }
30+
%>
2831
</center>
2932
</th>
3033
</tr>
@@ -34,9 +37,10 @@ table.button table td {
3437
<table>
3538
<tr>
3639
<th>
37-
<% if organization.official_img_header.attached? %>
40+
<%# if organization.official_img_header.attached? %>
41+
<% if organization.highlighted_content_banner_image.attached? %>
3842
<%= link_to organization.official_url do %>
39-
<%= image_tag organization.attached_uploader(:official_img_header).url(host: organization.host), alt: "", style: "max-height: 50px", class: "float-right" %>
43+
<%= image_tag organization.attached_uploader(:highlighted_content_banner_image).url, alt: "", style: "max-height: 50px", class: "float-right" %>
4044
<% end %>
4145
<% end %>
4246
</th>
@@ -119,9 +123,9 @@ table.button table td {
119123
<th class="small-12 first columns cityhall-bar">
120124
<div class="decidim-logo" style="float: right; text-align: right; padding-right: 16px">
121125
<% if @custom_url_for_mail_root.present? %>
122-
<%= link_to organization.name.html_safe, @custom_url_for_mail_root %>
126+
<%= link_to translated_attribute(organization.name).html_safe, @custom_url_for_mail_root %>
123127
<% else %>
124-
<%= link_to organization.name.html_safe, decidim.root_url(host: organization.host) %>
128+
<%= link_to translated_attribute(organization.name).html_safe, decidim.root_url(host: organization.host) %>
125129
<% end %>
126130
</div>
127131
</th>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<%#
2+
Decidim Zuerich Override
3+
4+
Created at: 2025-08-04
5+
Author: Thomas Burkhalter
6+
7+
Original:
8+
Module: decidim-core
9+
Template: app/views/layouts/decidim/_mailer_logo.html.erb
10+
11+
Why?:
12+
variant_url(:x, host: organization.host) tries to access the logo
13+
from the storage at organization.host, but since we're using a different
14+
domain for our S3 hosting, this fails.
15+
16+
We only use our code if the original code fails.
17+
18+
Additionally the cells system does not add our app/views to the view path,
19+
while it does load the original from decidim-core.
20+
That's why we decided to copy the templates to app/cells
21+
%>
22+
23+
24+
<% if organization %>
25+
<% if defined?(custom_url_for_mail_root) && custom_url_for_mail_root.present? %>
26+
<% url = custom_url_for_mail_root %>
27+
<% else %>
28+
<% url = decidim.root_url(host: organization.host) %>
29+
<% end %>
30+
<%= link_to url do %>
31+
<% if organization.logo.attached? %>
32+
<%=
33+
variant =
34+
begin
35+
organization.attached_uploader(:logo).variant_url(:medium, host: organization.host)
36+
rescue ArgumentError
37+
organization.attached_uploader(:logo).variant_url(:medium)
38+
end
39+
40+
image_tag(variant, style: "max-height: 50px", alt: organization_name(organization))
41+
%>
42+
<% else %>
43+
<span><%= organization_name(organization) %></span>
44+
<% end %>
45+
<% end %>
46+
<% else %>
47+
<%= Decidim.application_name %>
48+
<% end %>

0 commit comments

Comments
 (0)