Skip to content

Commit 27344a5

Browse files
authored
Normalize sponsor logos on the sponsors page (#1964)
1 parent 2c6ef18 commit 27344a5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sponsors/templatetags/sponsors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import math
2+
13
from collections import OrderedDict
24
from django import template
35
from django.conf import settings
@@ -69,3 +71,11 @@ def benefit_quantity_for_package(benefit, package):
6971
@register.simple_tag
7072
def benefit_name_for_display(benefit, package):
7173
return benefit.name_for_display(package=package)
74+
75+
76+
@register.filter
77+
def ideal_size(image, ideal_dimension):
78+
ideal_dimension = int(ideal_dimension)
79+
return int(
80+
image.width * math.sqrt((100 * ideal_dimension) / (image.width * image.height))
81+
)

templates/sponsors/partials/sponsors-list.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% load thumbnail %}
22
{% load cache %}
3+
{% load sponsors %}
34

45

56
{% if logo_place == "download" %}
@@ -46,7 +47,7 @@ <h1 style="font-size: {% if forloop.first %}350%{% else %}300%{% endif %}">{{ pa
4647
<div id={{ sponsorship.sponsor.name|slugify }}>
4748
<a href="{{ sponsorship.sponsor.landing_page_url }}">
4849
{% thumbnail sponsorship.sponsor.web_logo thumbnail_res format="PNG" quality=100 as im %}
49-
<img src="{{ im.url }}" alt="{{ sponsorship.sponsor.name }} logo" style="max-height:{{ im.height }}px;max-width:{{ im.width }}px;height:auto;width:auto;">
50+
<img src="{{ im.url }}" alt="{{ sponsorship.sponsor.name }} logo" style="max-width:{{ im|ideal_size:dimension }}px;height:auto;width:auto;">
5051
{% endthumbnail %}
5152
</a>
5253

0 commit comments

Comments
 (0)