pass through width and height of attachments to allow styling based on media orientation

main
Ash McAllan 2022-11-10 22:46:03 +00:00 committed by Thomas Sileo
parent afd253a1b4
commit 8f00e522d7
3 changed files with 10 additions and 2 deletions

View File

@ -275,6 +275,8 @@ class Attachment(BaseModel):
media_type: str | None
name: str | None
url: str
width: int
height: int
# Extra fields for the templates (and only for media)
proxied_url: str | None = None

View File

@ -251,6 +251,8 @@ class OutboxObject(Base, BaseObject):
"mediaType": attachment.upload.content_type,
"name": attachment.alt or attachment.filename,
"url": url,
"width":attachment.width,
"height":attachment.height,
"proxiedUrl": url,
"resizedUrl": BASE_URL
+ (

View File

@ -384,16 +384,20 @@
{% for attachment in object.attachments %}
{% if attachment.type != "PropertyValue" %}
{% set orientation = "unknown" %}
{% if attachment.width > 0 %}
{% set orientation = "portrait" if attachment.width < attachment.height else "landscape" %}
{% endif %}
{% if object.sensitive and (attachment.type == "Image" or (attachment | has_media_type("image")) or attachment.type == "Video" or (attachment | has_media_type("video"))) %}
<div class="attachment-wrapper">
<label for="{{attachment.proxied_url}}" class="label-btn show-hide-sensitive-btn">show/hide sensitive content</label>
<div>
<div class="sensitive-attachment">
<input class="sensitive-attachment-state" type="checkbox" id="{{attachment.proxied_url}}" aria-hidden="true">
<div class="sensitive-attachment-box">
<div class="sensitive-attachment-box {{oritenation}}">
<div></div>
{% else %}
<div class="attachment-item">
<div class="attachment-item {{orientation}}">
{% endif %}
{% if attachment.type == "Image" or (attachment | has_media_type("image")) %}