Handle inline images
This commit is contained in:
parent
11e64a2cc4
commit
77bc06545c
2 changed files with 17 additions and 0 deletions
|
@ -825,6 +825,12 @@
|
||||||
.timeline-deck .status .content.truncated ~ .card {
|
.timeline-deck .status .content.truncated ~ .card {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
.status .content .inner-content {
|
||||||
|
> img[height] {
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: var(--original-aspect-ratio);
|
||||||
|
}
|
||||||
|
}
|
||||||
.status .content .inner-content a:not(.mention, .has-url-text) {
|
.status .content .inner-content a:not(.mention, .has-url-text) {
|
||||||
color: var(--link-text-color);
|
color: var(--link-text-color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,6 +242,17 @@ function _enhanceContent(content, opts = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ADD ASPECT RATIO TO ALL IMAGES
|
||||||
|
if (enhancedContent.includes('<img')) {
|
||||||
|
dom.querySelectorAll('img').forEach((img) => {
|
||||||
|
const width = img.getAttribute('width') || img.naturalWidth;
|
||||||
|
const height = img.getAttribute('height') || img.naturalHeight;
|
||||||
|
if (width && height) {
|
||||||
|
img.style.setProperty('--original-aspect-ratio', `${width}/${height}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (postEnhanceDOM) {
|
if (postEnhanceDOM) {
|
||||||
queueMicrotask(() => postEnhanceDOM(dom));
|
queueMicrotask(() => postEnhanceDOM(dom));
|
||||||
// postEnhanceDOM(dom); // mutate dom
|
// postEnhanceDOM(dom); // mutate dom
|
||||||
|
|
Loading…
Add table
Reference in a new issue