Skip to content

Commit 1a18c1c

Browse files
authored
Merge pull request #114 from iMattPro/updates
Fix image lock out in PWAs
2 parents cbbb7c7 + 81fea3d commit 1a18c1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{# Disable opening attached images in Progressive Web Apps #}
2+
{% if S_VIEWTOPIC %}
3+
<script>
4+
const isStandalone = window.matchMedia('(display-mode: standalone)').matches
5+
|| window.navigator.standalone === true;
6+
7+
if (isStandalone) {
8+
document.querySelectorAll('a > img.postimage').forEach(img => {
9+
const link = img.closest('a');
10+
if (link) {
11+
link.addEventListener('click', e => {
12+
e.preventDefault();
13+
});
14+
}
15+
});
16+
}
17+
</script>
18+
{% endif %}

0 commit comments

Comments
 (0)