mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
pass through width and height of attachments to allow styling based on media orientation
This commit is contained in:
parent
afd253a1b4
commit
8f00e522d7
3 changed files with 10 additions and 2 deletions
|
@ -275,6 +275,8 @@ class Attachment(BaseModel):
|
||||||
media_type: str | None
|
media_type: str | None
|
||||||
name: str | None
|
name: str | None
|
||||||
url: str
|
url: str
|
||||||
|
width: int
|
||||||
|
height: int
|
||||||
|
|
||||||
# Extra fields for the templates (and only for media)
|
# Extra fields for the templates (and only for media)
|
||||||
proxied_url: str | None = None
|
proxied_url: str | None = None
|
||||||
|
|
|
@ -251,6 +251,8 @@ class OutboxObject(Base, BaseObject):
|
||||||
"mediaType": attachment.upload.content_type,
|
"mediaType": attachment.upload.content_type,
|
||||||
"name": attachment.alt or attachment.filename,
|
"name": attachment.alt or attachment.filename,
|
||||||
"url": url,
|
"url": url,
|
||||||
|
"width":attachment.width,
|
||||||
|
"height":attachment.height,
|
||||||
"proxiedUrl": url,
|
"proxiedUrl": url,
|
||||||
"resizedUrl": BASE_URL
|
"resizedUrl": BASE_URL
|
||||||
+ (
|
+ (
|
||||||
|
|
|
@ -384,16 +384,20 @@
|
||||||
|
|
||||||
{% for attachment in object.attachments %}
|
{% for attachment in object.attachments %}
|
||||||
{% if attachment.type != "PropertyValue" %}
|
{% 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"))) %}
|
{% 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">
|
<div class="attachment-wrapper">
|
||||||
<label for="{{attachment.proxied_url}}" class="label-btn show-hide-sensitive-btn">show/hide sensitive content</label>
|
<label for="{{attachment.proxied_url}}" class="label-btn show-hide-sensitive-btn">show/hide sensitive content</label>
|
||||||
<div>
|
<div>
|
||||||
<div class="sensitive-attachment">
|
<div class="sensitive-attachment">
|
||||||
<input class="sensitive-attachment-state" type="checkbox" id="{{attachment.proxied_url}}" aria-hidden="true">
|
<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>
|
<div></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="attachment-item">
|
<div class="attachment-item {{orientation}}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if attachment.type == "Image" or (attachment | has_media_type("image")) %}
|
{% if attachment.type == "Image" or (attachment | has_media_type("image")) %}
|
||||||
|
|
Loading…
Reference in a new issue