<div class="gallery-items"> <div class="gallery-photos"></div> </div>
<script> async function loadImages() { try { let url = 'https://memos.imsun.org' let response = await fetch(url + '/api/v1/memo?creatorId=1&tag=照片'); let data = await response.json(); let html = ''; let imgs = []; data.forEach(item => { let ls = item.content.match(/\!\[.*?\]\(.*?\)/g) if (ls) imgs = imgs.concat(ls) if (item.resourceList.length) { item.resourceList.forEach(t => { if (t.externalLink) imgs.push(`![](${t.externalLink})`) else imgs.push(`![](${url}/o/r/${t.id}/${t.publicId}/${t.filename})`) }) } })
if (imgs) imgs.forEach(item => { let img = item.replace(/!\[.*?\]\((.*?)\)/g, '$1'), time, title, tat = item.replace(/!\[(.*?)\]\(.*?\)/g, '$1') if (tat.indexOf(' ') != -1) { time = tat.split(' ')[0] title = tat.split(' ')[1] } else title = tat
html += `<figure class="gallery-group"> <a href='${img}' data-fancybox="gallery" data-caption="${title}"> <img data-grid-maintained-target="true" src='${img}' alt="Group Image Gallery" > <figcaption><p> ${title}</p></figcaption> </a> </figure>` })
document.querySelector('.gallery-photos').innerHTML = html } catch (error) { console.error('Failed to load images:', error); } }
if (1) { loadImages(); } </script>
|