mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
If there is only one media item on a tweet, ditch the aspect limitation
This commit is contained in:
parent
3b98e2cc14
commit
7771c7aa9d
@ -16,6 +16,7 @@ const schema = {
|
|||||||
entities: { media: [ {
|
entities: { media: [ {
|
||||||
type: true,
|
type: true,
|
||||||
media_url_https: true,
|
media_url_https: true,
|
||||||
|
dimensions: true,
|
||||||
video_info: { variants: [ {
|
video_info: { variants: [ {
|
||||||
url: true,
|
url: true,
|
||||||
content_type: true,
|
content_type: true,
|
||||||
@ -50,31 +51,35 @@ var entityProcessors = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
media (media, tweet) {
|
media (media, tweet) {
|
||||||
media.forEach((mediaObj) => {
|
media.forEach((m) => {
|
||||||
tweet.html = tweet.html.replace(mediaObj.url, '');
|
tweet.html = tweet.html.replace(m.url, '');
|
||||||
|
let width, height;
|
||||||
|
|
||||||
|
if (has(m, 'video_info.aspect_ratio')) {
|
||||||
|
[ width, height ] = m.video_info.aspect_ratio;
|
||||||
|
} else if (has(m, 'sizes.medium')) {
|
||||||
|
({ width, height } = m.sizes.medium);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (width && height) {
|
||||||
|
const ratioH = Math.round((height / width) * 100);
|
||||||
|
const ratioW = Math.round((width / height) * 100);
|
||||||
|
let orientation = 'wide';
|
||||||
|
if (ratioH > 100) {
|
||||||
|
orientation = 'tall';
|
||||||
|
} else if (ratioH === 100) {
|
||||||
|
orientation = 'square';
|
||||||
|
}
|
||||||
|
|
||||||
|
m.dimensions = {
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
ratioH,
|
||||||
|
ratioW,
|
||||||
|
orientation,
|
||||||
|
};
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if (mediaObj.type === 'photo') {
|
|
||||||
// // Use HTTPS if available
|
|
||||||
// var src = mediaObj.media_url_https ? mediaObj.media_url_https : mediaObj.media_url;
|
|
||||||
|
|
||||||
// if (options &&
|
|
||||||
// options.photoSize &&
|
|
||||||
// mediaObj.sizes &&
|
|
||||||
// mediaObj.sizes[options.photoSize]) {
|
|
||||||
// // If specified size is available, patch image src to use it
|
|
||||||
// src = src + ':' + options.photoSize;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// tweet.html = tweet.html.replace(mediaObj.url, `<img src="${src}" alt=""/>`);
|
|
||||||
// } else if (mediaObj.type === 'video') {
|
|
||||||
// var source = '';
|
|
||||||
// mediaObj.video_info.variants.forEach((info) => {
|
|
||||||
// source += `<source src="${info.url}" type="${info.content_type}">`;
|
|
||||||
// });
|
|
||||||
// var video = `<video controls poster="${mediaObj.media_url}">${source}</video>`;
|
|
||||||
// tweet.html = tweet.html.replace(mediaObj.url, video);
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -189,29 +189,44 @@
|
|||||||
grid-template: 1fr 1fr / 1fr 1fr;
|
grid-template: 1fr 1fr / 1fr 1fr;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
&.count1 .tweet-entity {
|
|
||||||
grid-row-end: span 2;
|
|
||||||
grid-column-end: span 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.count2 .tweet-entity {
|
|
||||||
grid-row-end: span 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.count3 .tweet-entity:first-child {
|
|
||||||
grid-row-end: span 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tweet-entity {
|
.tweet-entity {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: stretch;
|
justify-content: stretch;
|
||||||
|
img {
|
||||||
|
visibility: hidden;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tweet-entity > * {
|
.tweet-entity > * {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.entity-count-1 {
|
||||||
|
.tweet-entities-inner {
|
||||||
|
padding-bottom: 0;
|
||||||
|
> div {position: relative;}
|
||||||
|
}
|
||||||
|
|
||||||
|
.tweet-entities-grid {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.entity-count-1 .tweet-entity {
|
||||||
|
grid-row-end: span 2;
|
||||||
|
grid-column-end: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.entity-count-2 .tweet-entity {
|
||||||
|
grid-row-end: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.entity-count-3 .tweet-entity:first-child {
|
||||||
|
grid-row-end: span 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tweet-photo {
|
.tweet-photo {
|
||||||
|
@ -32,19 +32,27 @@
|
|||||||
{{/with}}{{/if}}
|
{{/with}}{{/if}}
|
||||||
<div class="tweet-text">{{{html}}}</div>
|
<div class="tweet-text">{{{html}}}</div>
|
||||||
{{#any extended_entities.media entities.media}}
|
{{#any extended_entities.media entities.media}}
|
||||||
<div class="tweet-entities lightbox"><div class="tweet-entities-inner"><div><div class="tweet-entities-grid count{{this.length}}">
|
<div class="tweet-entities lightbox entity-count-{{this.length}} entity-type-{{this.0.type}}"><div class="tweet-entities-inner"><div><div class="tweet-entities-grid">
|
||||||
{{#each this}}
|
{{#each this}}
|
||||||
<div class="tweet-entity">
|
<div class="tweet-entity">
|
||||||
{{#is type 'photo'}}<a class="tweet-photo lb" style="background-image: url({{media_url_https}}?name=medium);" href="{{media_url_https}}"></a>{{/is}}
|
{{#is type 'photo'}}
|
||||||
|
<a class="tweet-photo lb" style="background-image: url({{media_url_https}}?name=medium);" href="{{media_url_https}}">
|
||||||
|
<img src="{{media_url_https}}?name=medium">
|
||||||
|
</a>
|
||||||
|
{{/is}}
|
||||||
{{#is type 'video'}}
|
{{#is type 'video'}}
|
||||||
<video controls poster="{{media_url}}" class="tweet-video">
|
<video controls poster="{{media_url_https}}" class="tweet-video">
|
||||||
{{#each video_info.variants}}
|
{{#each video_info.variants}}
|
||||||
<source src="{{url}}" type="{{content_type}}">
|
<source src="{{url}}" type="{{content_type}}">
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</video>
|
</video>
|
||||||
{{/is}}
|
{{/is}}
|
||||||
{{#is type animated_gif}}
|
{{#is type 'animated_gif'}}
|
||||||
|
<video controls muted loop poster="{{media_url_https}}" class="tweet-video">
|
||||||
|
{{#each video_info.variants}}
|
||||||
|
<source src="{{url}}" type="{{content_type}}">
|
||||||
|
{{/each}}
|
||||||
|
</video>
|
||||||
{{/is}}
|
{{/is}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user