mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-12-22 05:04:27 +00:00
Tweak orientation hint for attachments
This commit is contained in:
parent
8f00e522d7
commit
48d5914851
3 changed files with 8 additions and 7 deletions
|
@ -275,13 +275,14 @@ 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
|
||||||
resized_url: str | None = None
|
resized_url: str | None = None
|
||||||
|
|
||||||
|
width: int | None = None
|
||||||
|
height: int | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mimetype(self) -> str:
|
def mimetype(self) -> str:
|
||||||
mimetype = self.media_type
|
mimetype = self.media_type
|
||||||
|
|
|
@ -251,8 +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,
|
"width": attachment.upload.width,
|
||||||
"height":attachment.height,
|
"height": attachment.upload.height,
|
||||||
"proxiedUrl": url,
|
"proxiedUrl": url,
|
||||||
"resizedUrl": BASE_URL
|
"resizedUrl": BASE_URL
|
||||||
+ (
|
+ (
|
||||||
|
|
|
@ -385,7 +385,7 @@
|
||||||
{% for attachment in object.attachments %}
|
{% for attachment in object.attachments %}
|
||||||
{% if attachment.type != "PropertyValue" %}
|
{% if attachment.type != "PropertyValue" %}
|
||||||
{% set orientation = "unknown" %}
|
{% set orientation = "unknown" %}
|
||||||
{% if attachment.width > 0 %}
|
{% if attachment.width %}
|
||||||
{% set orientation = "portrait" if attachment.width < attachment.height else "landscape" %}
|
{% set orientation = "portrait" if attachment.width < attachment.height else "landscape" %}
|
||||||
{% endif %}
|
{% 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"))) %}
|
||||||
|
@ -394,10 +394,10 @@
|
||||||
<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 {{oritenation}}">
|
<div class="sensitive-attachment-box attachment-orientation-{{orientation}}">
|
||||||
<div></div>
|
<div></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="attachment-item {{orientation}}">
|
<div class="attachment-item attachment-orientation-{{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