mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-28 00:56:23 +00:00
fix(TextRun): Add img element only if an URL is available
This commit is contained in:
@@ -43,10 +43,17 @@ export default class TextRun implements Run {
|
||||
|
||||
if (this.attachment) {
|
||||
if (this.attachment.element.type.imageType.image.sources.length) {
|
||||
const { url } = this.attachment.element.type.imageType.image.sources[0];
|
||||
if (this.endpoint) {
|
||||
const { url } = this.attachment.element.type.imageType.image.sources[0];
|
||||
|
||||
let image_el = '';
|
||||
|
||||
if (url) {
|
||||
image_el = `<img src="${url}" style="vertical-align: middle; height: ${this.attachment.element.properties.layoutProperties.height.value}px; width: ${this.attachment.element.properties.layoutProperties.width.value}px;" alt="">`;
|
||||
}
|
||||
|
||||
const nav_url = this.endpoint.toURL();
|
||||
if (nav_url) return `<a href="${nav_url}" class="yt-ch-link" display: block; width: fit-content; font-size: small;><img src="${url}" style="vertical-align: middle; height: ${this.attachment.element.properties.layoutProperties.height.value}px; width: ${this.attachment.element.properties.layoutProperties.width.value}px;">${wrapped_text}</a>`;
|
||||
if (nav_url) return `<a href="${nav_url}" class="yt-ch-link">${image_el}${wrapped_text}</a>`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user