+47
embed_component.js
+47
embed_component.js
···
125
126
a.append(box);
127
128
+
if (hostname == 'media.tenor.com') {
129
+
a.addEventListener('click', (e) => {
130
+
e.preventDefault();
131
+
this.displayGIFInline(a, embed);
132
+
});
133
+
}
134
+
135
return a;
136
+
}
137
+
138
+
/** @param {HTMLElement} a, @param {RawLinkEmbed | InlineLinkEmbed} embed */
139
+
140
+
displayGIFInline(a, embed) {
141
+
let gifDiv = $tag('div.gif');
142
+
let img = $tag('img', { src: embed.url }, HTMLImageElement);
143
+
img.style.opacity = '0';
144
+
img.style.maxHeight = '200px';
145
+
gifDiv.append(img);
146
+
a.replaceWith(gifDiv);
147
+
148
+
img.addEventListener('load', (e) => {
149
+
if (img.naturalWidth > img.naturalHeight) {
150
+
img.style.maxHeight = '200px';
151
+
} else {
152
+
img.style.maxWidth = '200px';
153
+
img.style.maxHeight = '400px';
154
+
}
155
+
156
+
img.style.opacity = '';
157
+
});
158
+
159
+
let staticPic;
160
+
161
+
if (typeof embed.thumb == 'string') {
162
+
staticPic = embed.thumb;
163
+
} else {
164
+
staticPic = `https://cdn.bsky.app/img/avatar/plain/${this.post.author.did}/${embed.thumb.ref.$link}@jpeg`;
165
+
}
166
+
167
+
img.addEventListener('click', (e) => {
168
+
if (img.classList.contains('static')) {
169
+
img.src = embed.url;
170
+
img.classList.remove('static');
171
+
} else {
172
+
img.src = staticPic;
173
+
img.classList.add('static');
174
+
}
175
+
});
176
}
177
178
/** @param {FeedGeneratorRecord} feedgen, @returns {HTMLElement} */
+2
models.js
+2
models.js
···
650
651
this.url = json.external.uri;
652
this.title = json.external.title;
653
+
this.thumb = json.external.thumb;
654
}
655
}
656
···
719
this.url = json.external.uri;
720
this.title = json.external.title;
721
this.description = json.external.description;
722
+
this.thumb = json.external.thumb;
723
}
724
}
725
+9
style.css
+9
style.css