Update image rendering to preserve aspect ratio by removing height attribute
All checks were successful
Deploy to Server / deploy (push) Successful in 10s
All checks were successful
Deploy to Server / deploy (push) Successful in 10s
This commit is contained in:
parent
3b8e0b17dc
commit
bbdcc80334
4 changed files with 28 additions and 3 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<!-- Campaign image -->
|
<!-- Campaign image -->
|
||||||
{% if campaign.image_best_url %}
|
{% if campaign.image_best_url %}
|
||||||
{% picture campaign.image_best_url alt=campaign.name width=160 height=160 %}
|
{% picture campaign.image_best_url alt=campaign.name width=160 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- Campaign description -->
|
<!-- Campaign description -->
|
||||||
<p>{{ campaign.description|linebreaksbr }}</p>
|
<p>{{ campaign.description|linebreaksbr }}</p>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Game image -->
|
<!-- Game image -->
|
||||||
{% if game.box_art_best_url %}
|
{% if game.box_art_best_url %}
|
||||||
{% picture game.box_art_best_url alt=game.name width=160 height=160 %}
|
{% picture game.box_art_best_url alt=game.name width=160 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- Game owner -->
|
<!-- Game owner -->
|
||||||
{% if owners %}
|
{% if owners %}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
</p>
|
</p>
|
||||||
<!-- Campaign image -->
|
<!-- Campaign image -->
|
||||||
{% if reward_campaign.image_best_url %}
|
{% if reward_campaign.image_best_url %}
|
||||||
{% picture reward_campaign.image_best_url alt=reward_campaign.name width=160 height=160 %}
|
{% picture reward_campaign.image_best_url alt=reward_campaign.name width=160 %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<!-- RSS Feeds -->
|
<!-- RSS Feeds -->
|
||||||
<div style="margin-bottom: 1rem;">
|
<div style="margin-bottom: 1rem;">
|
||||||
|
|
|
||||||
|
|
@ -930,6 +930,31 @@ class TestChannelListView:
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "game" in response.context
|
assert "game" in response.context
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_game_detail_image_aspect_ratio(self, client: Client, db: object) -> None:
|
||||||
|
"""Box art should render with a width attribute only, preserving aspect ratio."""
|
||||||
|
game: Game = Game.objects.create(
|
||||||
|
twitch_id="g3",
|
||||||
|
name="Game3",
|
||||||
|
display_name="Game3",
|
||||||
|
)
|
||||||
|
# property is derived; write to underlying field
|
||||||
|
game.box_art = "https://example.com/boxart.png"
|
||||||
|
game.save()
|
||||||
|
url: str = reverse("twitch:game_detail", args=[game.twitch_id])
|
||||||
|
response: _MonkeyPatchedWSGIResponse = client.get(url)
|
||||||
|
html: str = response.content.decode("utf-8")
|
||||||
|
# the picture tag should include the width but not an explicit height
|
||||||
|
assert 'width="160"' in html
|
||||||
|
# ensure the height attribute is not part of the same img element
|
||||||
|
assert (
|
||||||
|
"height="
|
||||||
|
not in html.split("https://example.com/boxart.png")[1].split(
|
||||||
|
">",
|
||||||
|
maxsplit=1,
|
||||||
|
)[0]
|
||||||
|
)
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_game_detail_view_serializes_owners_field(
|
def test_game_detail_view_serializes_owners_field(
|
||||||
self,
|
self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue