diff --git a/lib/css/chat-common.css b/lib/css/chat-common.css index d2d50684..20112bbd 100644 --- a/lib/css/chat-common.css +++ b/lib/css/chat-common.css @@ -110,6 +110,10 @@ html,body { font-size: 1.2rem; line-height: 1.6rem; } +#topic-value > .image-container > img { + max-height: 6em; + cursor: zoom-in; +} #topic .edit.button { position: absolute; top: .2rem; diff --git a/lib/js/chat.js b/lib/js/chat.js index 350351dc..9ce52a8a 100644 --- a/lib/js/chat.js +++ b/lib/js/chat.js @@ -1051,7 +1051,30 @@ function wordMark (comm){ let rawTopic = ''; function topicChange (topicValue){ rawTopic = topicValue || ''; - document.getElementById("topic-value").innerHTML = tagConvert(rawTopic); + const topicElement = document.getElementById("topic-value"); + topicElement.innerHTML = tagConvert(rawTopic); + + topicElement.querySelectorAll('a[href]').forEach( + hyperlinkElement => { + const uri = hyperlinkElement.getAttribute('href'); + if (!uri.match(/\.(png|gif|webp|jpe?g|svg)($|\?)/i)) { + return; + } + + const imageElement = document.createElement('img'); + imageElement.setAttribute('src', uri); + imageElement.setAttribute('loading', 'lazy'); + + const imageContainerElement = document.createElement('span'); + imageContainerElement.classList.add('image-container'); + imageContainerElement.append(imageElement); + + hyperlinkElement.after(imageContainerElement); + hyperlinkElement.parentNode.removeChild(hyperlinkElement); + + imageElement.addEventListener('click', () => imgView(uri)); + } + ); } // ステータス表更新 ---------------------------------------- function statusUpdate () {